]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
glob: Fix buffer overflow during GLOB_TILDE unescaping [BZ #22332]
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 22 Oct 2017 08:00:57 +0000 (10:00 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Sun, 22 Oct 2017 08:01:24 +0000 (10:01 +0200)
ChangeLog
NEWS
posix/glob.c

index bc15aef2baa8bac33712f0d7a2021412f938a5cc..d2f0858f845e41cae3bb51b3c69e4f950b68e617 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 c38fb88ac4327bc2103ab3e3c3cc081c7a50aaa4..8e040f1f3b01c71d12dd01be8efddf9037cf6e10 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -82,6 +82,10 @@ Security related changes:
   processing, leading to a memory leak and, potentially, to a denial
   of service.
 
+  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.
+
 The following bugs are resolved with this release:
 
   [The release manager will add the list generated by
index 15a6c0cf13bdccb7972183884f87c5d4be2a2f1b..cb39779d0716d430b0580d2493f56e38f832cb79 100644 (file)
@@ -770,11 +770,11 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
                  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