From: Paul Eggert Date: Sun, 22 Oct 2017 08:00:57 +0000 (+0200) Subject: glob: Fix buffer overflow during GLOB_TILDE unescaping [BZ #22332] X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49a0c33ead1b1eea5b414e9e2574a4fd96291203;p=thirdparty%2Fglibc.git glob: Fix buffer overflow during GLOB_TILDE unescaping [BZ #22332] (cherry picked from commit a159b53fa059947cc2548e3b0d5bdcf7b9630ba8) --- diff --git a/ChangeLog b/ChangeLog index c17787e785f..5aa721d3beb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2017-10-22 Paul Eggert + + [BZ #22332] + * posix/glob.c (__glob): Fix buffer overflow during GLOB_TILDE + unescaping. + 2017-10-21 Florian Weimer * posix/Makefile (tests): Add tst-glob-tilde. diff --git a/NEWS b/NEWS index d79e8bcaa13..f67abd6af04 100644 --- 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. + Version 2.22 diff --git a/posix/glob.c b/posix/glob.c index cd28dc52a25..944b77b4dda 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -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