NetBSD Problem Report #30833
From www@netbsd.org Mon Jul 25 14:47:04 2005
Return-Path: <www@netbsd.org>
Received: by narn.netbsd.org (Postfix, from userid 31301)
id E31F263B11B; Mon, 25 Jul 2005 14:47:03 +0000 (UTC)
Message-Id: <20050725144703.E31F263B11B@narn.netbsd.org>
Date: Mon, 25 Jul 2005 14:47:03 +0000 (UTC)
From: tomska@packetfront.com
Reply-To: tomska@packetfront.com
To: gnats-bugs@netbsd.org
Subject: Buffer overflow in lib/libc/gen/__glob13.c
X-Send-Pr-Version: www-1.0
>Number: 30833
>Category: lib
>Synopsis: Buffer overflow in lib/libc/gen/__glob13.c
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: elad
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jul 25 14:48:00 +0000 2005
>Closed-Date: Sat Sep 17 19:14:30 +0000 2005
>Last-Modified: Sat Dec 02 12:50:05 +0000 2006
>Originator: Tomas Skäre
>Release: 1.6
>Organization:
PacketFront
>Environment:
>Description:
Static code analysis run on NetBSD kernel showed an error in lib/libc/gen/__glob13.c. There is a possible buffer overflow in
glob1() (called from glob0, which is called from glob). It also
exists in current CVS head.
On row 604:
return(glob2(pathbuf, pathbuf, pathbuf + sizeof(pathbuf) - 1, pattern,
pglob, limit));
pathbuf is declared as:
Char pathbuf[MAXPATHLEN+1];
Where the type "Char" is u_short when DEBUG is not set.
sizeof(pathbuf) therefore returns 2 * (MAXPATHLEN+1), and when this is applied in pointer arithmetics with pointers of the type Char (u_short) it will double once more (as it should), so "pathbuf + sizeof(pathbuf) - 1" will not point at the end of pathbuf but rather MAXPATHLEN further beyond it.
>How-To-Repeat:
>Fix:
Replacing sizeof(pathbuf) with MAXPATHLEN should probably work.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: lib-bug-people->elad
Responsible-Changed-By: elad@netbsd.org
Responsible-Changed-When: Sat, 20 Aug 2005 13:21:15 +0000
Responsible-Changed-Why:
I'll solve it.
From: Elad Efrat <elad@netbsd.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: PR/30833 CVS commit: src/lib/libc/gen
Date: Tue, 13 Sep 2005 21:38:03 +0000 (UTC)
Module Name: src
Committed By: elad
Date: Tue Sep 13 21:38:03 UTC 2005
Modified Files:
src/lib/libc/gen: glob.c
Log Message:
Don't overflow when DEBUG is defined.
PR/30833, from Tomas Skare.
To generate a diff of this commit:
cvs rdiff -r1.12 -r1.13 src/lib/libc/gen/glob.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: elad@netbsd.org
State-Changed-When: Sat, 17 Sep 2005 19:14:30 +0000
State-Changed-Why:
I fixed it.
From: Luke Mewburn <lukem@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: PR/30833 CVS commit: othersrc/libexec/tnftpd/libnetbsd
Date: Tue, 26 Sep 2006 02:16:43 +0000 (UTC)
Module Name: othersrc
Committed By: lukem
Date: Tue Sep 26 02:16:43 UTC 2006
Modified Files:
othersrc/libexec/tnftpd/libnetbsd: ftpglob.h glob.c
Log Message:
Sync to NetBSD glob.h 1.21, glob.c 1.16:
* PR/33123: Murray Armfield: standards compliance & glob.h
Certain fields in glob.h need to be size_t
* Use __gl_stat_t instead of struct stat
* Don't overflow when DEBUG is defined.
PR/30833, from Tomas Skare.
* Use a separate macro, not DEBUG to enforce 8 bit chars [glob uses internally
16 bit chars]. Fix lint complaint when compiling with 8 bit chars.
* Use strlcpy() instead of strcpy()
To generate a diff of this commit:
cvs rdiff -r1.2 -r1.3 othersrc/libexec/tnftpd/libnetbsd/ftpglob.h \
othersrc/libexec/tnftpd/libnetbsd/glob.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: PR/30833 CVS commit: [netbsd-3] src/lib/libc/gen
Date: Sat, 2 Dec 2006 12:38:03 +0000 (UTC)
Module Name: src
Committed By: bouyer
Date: Sat Dec 2 12:38:03 UTC 2006
Modified Files:
src/lib/libc/gen [netbsd-3]: __glob13.c
Log Message:
Pull up following revision(s) (requested by joerg in ticket #1596):
lib/libc/gen/glob.c: revision 1.13 via patch
Don't overflow when DEBUG is defined.
PR/30833, from Tomas Skare.
To generate a diff of this commit:
cvs rdiff -r1.25.6.3 -r1.25.6.4 src/lib/libc/gen/__glob13.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: PR/30833 CVS commit: [netbsd-3-0] src/lib/libc/gen
Date: Sat, 2 Dec 2006 12:38:15 +0000 (UTC)
Module Name: src
Committed By: bouyer
Date: Sat Dec 2 12:38:15 UTC 2006
Modified Files:
src/lib/libc/gen [netbsd-3-0]: __glob13.c
Log Message:
Pull up following revision(s) (requested by joerg in ticket #1596):
lib/libc/gen/glob.c: revision 1.13 via patch
Don't overflow when DEBUG is defined.
PR/30833, from Tomas Skare.
To generate a diff of this commit:
cvs rdiff -r1.25.6.3 -r1.25.6.3.2.1 src/lib/libc/gen/__glob13.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: PR/30833 CVS commit: [netbsd-3-1] src/lib/libc/gen
Date: Sat, 2 Dec 2006 12:38:25 +0000 (UTC)
Module Name: src
Committed By: bouyer
Date: Sat Dec 2 12:38:25 UTC 2006
Modified Files:
src/lib/libc/gen [netbsd-3-1]: __glob13.c
Log Message:
Pull up following revision(s) (requested by joerg in ticket #1596):
lib/libc/gen/glob.c: revision 1.13 via patch
Don't overflow when DEBUG is defined.
PR/30833, from Tomas Skare.
To generate a diff of this commit:
cvs rdiff -r1.25.6.3 -r1.25.6.3.4.1 src/lib/libc/gen/__glob13.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: PR/30833 CVS commit: [netbsd-2] src/lib/libc/gen
Date: Sat, 2 Dec 2006 12:45:02 +0000 (UTC)
Module Name: src
Committed By: bouyer
Date: Sat Dec 2 12:45:02 UTC 2006
Modified Files:
src/lib/libc/gen [netbsd-2]: __glob13.c
Log Message:
Pull up following revision(s) (requested by joerg in ticket #10789):
lib/libc/gen/glob.c: revision 1.13 via patch
Don't overflow when DEBUG is defined.
PR/30833, from Tomas Skare.
To generate a diff of this commit:
cvs rdiff -r1.25 -r1.25.4.1 src/lib/libc/gen/__glob13.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: PR/30833 CVS commit: [netbsd-2-0] src/lib/libc/gen
Date: Sat, 2 Dec 2006 12:45:12 +0000 (UTC)
Module Name: src
Committed By: bouyer
Date: Sat Dec 2 12:45:12 UTC 2006
Modified Files:
src/lib/libc/gen [netbsd-2-0]: __glob13.c
Log Message:
Pull up following revision(s) (requested by joerg in ticket #10789):
lib/libc/gen/glob.c: revision 1.13 via patch
Don't overflow when DEBUG is defined.
PR/30833, from Tomas Skare.
To generate a diff of this commit:
cvs rdiff -r1.25 -r1.25.2.1 src/lib/libc/gen/__glob13.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: PR/30833 CVS commit: [netbsd-2-1] src/lib/libc/gen
Date: Sat, 2 Dec 2006 12:45:23 +0000 (UTC)
Module Name: src
Committed By: bouyer
Date: Sat Dec 2 12:45:22 UTC 2006
Modified Files:
src/lib/libc/gen [netbsd-2-1]: __glob13.c
Log Message:
Pull up following revision(s) (requested by joerg in ticket #10789):
lib/libc/gen/glob.c: revision 1.13 via patch
Don't overflow when DEBUG is defined.
PR/30833, from Tomas Skare.
To generate a diff of this commit:
cvs rdiff -r1.25 -r1.25.8.1 src/lib/libc/gen/__glob13.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.