fa3bfd
commit a159b53fa059947cc2548e3b0d5bdcf7b9630ba8
fa3bfd
Author: Paul Eggert <eggert@cs.ucla.edu>
fa3bfd
Date:   Sun Oct 22 10:00:57 2017 +0200
fa3bfd
fa3bfd
    glob: Fix buffer overflow during GLOB_TILDE unescaping [BZ #22332]
fa3bfd
fa3bfd
CVE-2017-15804 was assigned to this issue after commit.
fa3bfd
fa3bfd
diff --git a/posix/glob.c b/posix/glob.c
fa3bfd
index 15cf3d5cccab0ee0..e09314712d68c1b8 100644
fa3bfd
--- a/posix/glob.c
fa3bfd
+++ b/posix/glob.c
fa3bfd
@@ -806,11 +806,11 @@ glob (pattern, flags, errfunc, pglob)
fa3bfd
 		  char *p = mempcpy (newp, dirname + 1,
fa3bfd
 				     unescape - dirname - 1);
fa3bfd
 		  char *q = unescape;
fa3bfd
-		  while (*q != '\0')
fa3bfd
+		  while (q != end_name)
fa3bfd
 		    {
fa3bfd
 		      if (*q == '\\')
fa3bfd
 			{
fa3bfd
-			  if (q[1] == '\0')
fa3bfd
+			  if (q + 1 == end_name)
fa3bfd
 			    {
fa3bfd
 			      /* "~fo\\o\\" unescape to user_name "foo\\",
fa3bfd
 				 but "~fo\\o\\/" unescape to user_name