Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Mar 2002 21:54:13 +1100 (EST)
From:      "Tim J. Robbins" <tim@robbins.dropbear.id.au>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/35590: [PATCH] Sloppy argument checking in expand(1) -> buffer overflow
Message-ID:  <200203061054.g26AsDX32399@descent.robbins.dropbear.id.au>

next in thread | raw e-mail | index | archive | help

>Number:         35590
>Category:       bin
>Synopsis:       [PATCH] Sloppy argument checking in expand(1) -> buffer overflow
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 06 03:00:07 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Tim J. Robbins
>Release:        FreeBSD 4.5-STABLE i386
>Organization:
>Environment:
System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #5: Sat Feb 16 18:56:18 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386


	
>Description:
expand(1) doesn't check that too many tab stops aren't specified with the
-t option which leads to a buffer overflow. Not a security problem, but
it is a bug and sloppy programming.
>How-To-Repeat:
tim@descent$ expand -t`jot 1000 | tr '\n' ','`
Memory fault(coredump)
>Fix:

Index: expand/expand.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/expand/expand.c,v
retrieving revision 1.8
diff -u -r1.8 expand.c
--- expand/expand.c	2001/06/24 19:50:35	1.8
+++ expand/expand.c	2002/03/06 10:51:52
@@ -162,6 +162,8 @@
 			errx(1, "bad tab stop spec");
 		if (nstops > 0 && i <= tabstops[nstops-1])
 			errx(1, "bad tab stop spec");
+		if (nstops == sizeof(tabstops) / sizeof(*tabstops))
+			errx(1, "too many tab stops");
 		tabstops[nstops++] = i;
 		if (*cp == 0)
 			break;
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203061054.g26AsDX32399>