public inbox for libc-stable@sourceware.org
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: libc-stable@sourceware.org
Cc: Paul Eggert <eggert@cs.ucla.edu>
Subject: [COMMITTED 2.25 6/8] glob: Fix buffer overflow during GLOB_TILDE unescaping [BZ #22332]
Date: Sun, 01 Jan 2017 00:00:00 -0000	[thread overview]
Message-ID: <20171202095206.9955-6-aurelien@aurel32.net> (raw)
In-Reply-To: <20171202095206.9955-1-aurelien@aurel32.net>

From: Paul Eggert <eggert@cs.ucla.edu>

(cherry picked from commit a159b53fa059947cc2548e3b0d5bdcf7b9630ba8)
---
 ChangeLog    | 6 ++++++
 NEWS         | 4 ++++
 posix/glob.c | 4 ++--
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c19862d829..951fe6f882 100644
--- 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 c353ce6273..40ecd30fc5 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,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:
 
   [20257] sunrpc: clntudp_call does not enforce timeout when receiving data
diff --git a/posix/glob.c b/posix/glob.c
index c761c0861d..b2273ea7bc 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -850,11 +850,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
-- 
2.15.0

  parent reply	other threads:[~2017-12-02  9:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-01  0:00 [COMMITTED 2.25 1/8] i386: Hide __old_glob64 [BZ #18822] Aurelien Jarno
2017-01-01  0:00 ` [COMMITTED 2.25 3/8] CVE-2017-15670: glob: Fix one-byte overflow [BZ #22320] Aurelien Jarno
2017-01-01  0:00   ` Dmitry V. Levin
2017-01-01  0:00     ` Aurelien Jarno
2017-01-01  0:00 ` Aurelien Jarno [this message]
2017-01-01  0:00 ` [COMMITTED 2.25 2/8] posix: Sync glob with gnulib [BZ #1062] Aurelien Jarno
2017-01-01  0:00 ` [COMMITTED 2.25 5/8] Update NEWS and ChangeLog for CVE-2017-15671 Aurelien Jarno
2017-01-01  0:00 ` [COMMITTED 2.25 8/8] Update NEWS to add CVE-2017-15804 entry Aurelien Jarno
2017-01-01  0:00 ` [COMMITTED 2.25 7/8] posix/tst-glob-tilde.c: Add test for bug 22332 Aurelien Jarno
2017-01-01  0:00 ` [COMMITTED 2.25 4/8] glob: Add new test tst-glob-tilde Aurelien Jarno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171202095206.9955-6-aurelien@aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=eggert@cs.ucla.edu \
    --cc=libc-stable@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).