summaryrefslogtreecommitdiff
path: root/posix/glob.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2017-10-22 10:00:57 +0200
committerAurelien Jarno <aurelien@aurel32.net>2017-12-02 22:58:11 +0100
commit94825c8924b80518214ad9e3ca1f6589f209592c (patch)
tree52f689273f95f904bfb3d63113ff5c20d1175088 /posix/glob.c
parent1e53b88296dc95d325d6073910a33dca851b6bc4 (diff)
downloadglibc-94825c8924b80518214ad9e3ca1f6589f209592c.tar.gz
glob: Fix buffer overflow during GLOB_TILDE unescaping [BZ #22332]
(cherry picked from commit a159b53fa059947cc2548e3b0d5bdcf7b9630ba8)
Diffstat (limited to 'posix/glob.c')
-rw-r--r--posix/glob.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/posix/glob.c b/posix/glob.c
index 026bc063d3..f3fa807700 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -863,11 +863,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