QElfParser: double check section size before using it.
authorArvid E. Picciani <arvid.picciani@nokia.com>
Tue, 15 May 2012 10:29:53 +0000 (12:29 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 16 May 2012 02:25:07 +0000 (04:25 +0200)
In rare cases, if the section is empty, we're reading the whole object
into memory because size -1 = UINT_MAX.

Change-Id: Ibf9a1534159ce626e4f2327536076d0cc1ebf0ba
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
src/corelib/plugin/qelfparser_p.cpp

index af2fc44..e4215dc 100644 (file)
@@ -218,7 +218,7 @@ int QElfParser::parse(const char *dataStart, ulong fdlen, const QString &library
                 continue;
             }
 
-            if (sh.offset == 0 || (sh.offset + sh.size) > fdlen) {
+            if (sh.offset == 0 || (sh.offset + sh.size) > fdlen || sh.size < 1) {
                 if (lib)
                     lib->errorString = QLibrary::tr("'%1' is an invalid ELF object (%2)").arg(library)
                                       .arg(QLatin1String("missing section data. This is not a library."));