]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
glob: Fix buffer overflow during GLOB_TILDE unescaping [BZ #22332] release/2.22/master
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 22 Oct 2017 08:00:57 +0000 (10:00 +0200)
committerTulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Fri, 13 Apr 2018 17:30:20 +0000 (14:30 -0300)
(cherry picked from commit a159b53fa059947cc2548e3b0d5bdcf7b9630ba8)

ChangeLog
NEWS
posix/glob.c

index c17787e785f9f93b27935e194f4d8fc288171b07..5aa721d3beb7997d01549e2d21a26a596783cc5f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-10-22  Paul Eggert <eggert@cs.ucla.edu>
+
+       [BZ #22332]
+       * posix/glob.c (__glob): Fix buffer overflow during GLOB_TILDE
+       unescaping.
+
 2017-10-21  Florian Weimer  <fweimer@redhat.com>
 
        * posix/Makefile (tests): Add tst-glob-tilde.
diff --git a/NEWS b/NEWS
index d79e8bcaa13fddf13d2153f5dc5c0c7184b5cc29..f67abd6af047fd962e39d2abb7649cba1a1efc86 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -100,6 +100,10 @@ Version 2.22.1
   from a one-byte overflow during ~ operator processing (either on the stack
   or the heap, depending on the length of the user name).
 
+* CVE-2017-15804: The glob function, when invoked with GLOB_TILDE and without
+  GLOB_NOESCAPE, could write past the end of a buffer while
+  unescaping user names.  Reported by Tim Rühsen.
+
 \f
 Version 2.22
 
index cd28dc52a25199dc89e8e685cd72375ce5ce1243..944b77b4dda30581e1bb8a2215958be7eeff49b4 100644 (file)
@@ -866,11 +866,11 @@ glob (pattern, flags, errfunc, pglob)
                  char *p = mempcpy (newp, dirname + 1,
                                     unescape - dirname - 1);
                  char *q = unescape;
-                 while (*q != '\0')
+                 while (q != end_name)
                    {
                      if (*q == '\\')
                        {
-                         if (q[1] == '\0')
+                         if (q + 1 == end_name)
                            {
                              /* "~fo\\o\\" unescape to user_name "foo\\",
                                 but "~fo\\o\\/" unescape to user_name