Date: Fri, 12 Mar 2004 07:24:53 -0800 (PST) From: Claes M Nyberg <md0claes@mdstud.chalmers.se> To: freebsd-gnats-submit@FreeBSD.org Subject: misc/64164: Buffer overflow in /usr/bin/indent Message-ID: <200403121524.i2CFOrUr083531@www.freebsd.org> Resent-Message-ID: <200403121530.i2CFUMFP051109@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 64164 >Category: misc >Synopsis: Buffer overflow in /usr/bin/indent >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: Fri Mar 12 07:30:22 PST 2004 >Closed-Date: >Last-Modified: >Originator: Claes M Nyberg >Release: 5.1-RELEASE >Organization: >Environment: FreeBSD mastercom.powerland.box 5.1-RELEASE FreeBSD 5.1-RELEASE #2: Mon Oct 20 21:06:14 CEST 2003 cmn@mastercom.powerland.box:/usr/src/sys/i386/compile/MASTERCOM i386 >Description: /usr/bin/indent crashes with a long HOME environmental variable. Line 171 in args.c: sprintf(fname, "%s/%s", getenv("HOME"), prof); Other locations that lacks boundary checking (which might, or might not crash the program): cd /usr/src/usr.bin/indent $ iseec -v *.c Parsing 'args.c' Parsing 'indent.c' Parsing 'io.c' Parsing 'lexi.c' Parsing 'parse.c' Parsing 'pr_comment.c' Function "main" found on line 73 in file indent.c Found 19 global and 5 private functions in 6 files (iseec) audit efuncs -vvvv Using sprintf Using strcpy Using creat Using getc Using getenv (iseec) audit efuncs Using sprintf Using strcpy (iseec) calls --to sprintf -a Function 'sprintf' not found in global table Found function 'sprintf' in external table [indent.c:501] main -> sprintf [indent.c:572] main -> sprintf [indent.c:914] main -> sprintf [args.c:171] set_profile -> sprintf [indent.c:1154] bakcopy -> sprintf (iseec) print indent.c -s 501 -l1 sprintf(e_code, "\n.Du %dp+\200p \"%s\"\n", dec_ind * 7, token); (iseec) print indent.c -s 572 -l1 sprintf(e_code, "\n.Du %dp+\200p \"%s\"\n", dec_ind * 7, token); (iseec) print indent.c -s 914 -l1 sprintf(e_code, "\n.De %dp+\200p\n", dec_ind * 7); (iseec) print args.c -s 171 -l1 sprintf(fname, "%s/%s", getenv("HOME"), prof); (iseec) print indent.c -s 1154 sprintf(bakfile, "%s.BAK", p); (iseec) >How-To-Repeat: $ export HOME=`perl -e'{ print "A"x8192; }'` $ gdb `which indent` GNU gdb 5.2.1 (FreeBSD) Copyright 2002 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-undermydesk-freebsd"... (no debugging symbols found)... (gdb) r Starting program: /usr/bin/indent (no debugging symbols found)...(no debugging symbols found)... Program received signal SIGSEGV, Segmentation fault. 0x41414141 in ?? () (gdb) >Fix: Use snprintf(3) instead of sprintf(3). >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403121524.i2CFOrUr083531>