]> git.saurik.com Git - apt.git/commitdiff
Fix buffer overflow in debListParser::VersionHash()
authorJulian Andres Klode <jak@debian.org>
Tue, 28 Jun 2016 08:24:11 +0000 (10:24 +0200)
committerJulian Andres Klode <jak@debian.org>
Tue, 28 Jun 2016 20:15:50 +0000 (22:15 +0200)
If a package file is formatted in a way that that no space
follows a deprecated "<", we would reformat it to "<=" and
increase the length of the output by 1, which can break.

Under normal circumstances with "<=" this should not be an
issue.

Closes: #828812
apt-pkg/deb/deblistparser.cc

index ed5484ad97a0a5720134dffcc137ee1763ff1ce4..e24ced27189fff38650ab555f29623c585e99c56 100644 (file)
@@ -357,8 +357,12 @@ unsigned short debListParser::VersionHash()
            continue;
         *J++ = tolower_ascii(*Start);
 
-        if ((*Start == '<' || *Start == '>') && Start[1] != *Start && Start[1] != '=')
-           *J++ = '=';
+        /* Normalize <= to < and >= to >. This is the wrong way around, but
+         * more efficient that the right way. And since we're only hashing
+         * it does not matter which way we normalize. */
+        if ((*Start == '<' || *Start == '>') && Start[1] == '=') {
+           Start++;
+        }
       }
 
       Result = AddCRC16(Result,S,J - S);