Просмотр исходного кода

dpkg-deb: Do not look for newline beyond the buffer in read_line()

Depending on how the stack grows read_line() could go beyond the end
of the buffer when looking for a newline.
Guillem Jover лет назад: 14
Родитель
Сommit
c0d7a6552b
2 измененных файлов с 4 добавлено и 1 удалено
  1. 3 0
      debian/changelog
  2. 1 1
      dpkg-deb/extract.c

+ 3 - 0
debian/changelog

@@ -1,5 +1,8 @@
 dpkg (1.16.3) UNRELEASED; urgency=low
 
+  [ Guillem Jover ]
+  * Do not look for newline beyond the read buffer on dpkg-deb extract.
+
   [ Updated dpkg translations ]
   * French (Christian Perrier)
   * German (Sven Joachim).

+ 1 - 1
dpkg-deb/extract.c

@@ -86,7 +86,7 @@ read_line(int fd, char *buf, size_t min_size, size_t max_size)
     if (r <= 0)
       return r;
 
-    nl = strchr(buf + line_size, '\n');
+    nl = memchr(buf + line_size, '\n', r);
     line_size += r;
 
     if (nl != NULL) {