From owner-freebsd-bugs@FreeBSD.ORG Fri Mar 12 07:30:23 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 38FC016A4CE for ; Fri, 12 Mar 2004 07:30:23 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1C19943D1F for ; Fri, 12 Mar 2004 07:30:23 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i2CFUMbv051112 for ; Fri, 12 Mar 2004 07:30:23 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i2CFUMFP051109; Fri, 12 Mar 2004 07:30:22 -0800 (PST) (envelope-from gnats) Resent-Date: Fri, 12 Mar 2004 07:30:22 -0800 (PST) Resent-Message-Id: <200403121530.i2CFUMFP051109@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Claes M Nyberg Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B1DA916A4CE for ; Fri, 12 Mar 2004 07:24:53 -0800 (PST) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9085B43D1F for ; Fri, 12 Mar 2004 07:24:53 -0800 (PST) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.12.10/8.12.10) with ESMTP id i2CFOr72083532 for ; Fri, 12 Mar 2004 07:24:53 -0800 (PST) (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.10/8.12.10/Submit) id i2CFOrUr083531; Fri, 12 Mar 2004 07:24:53 -0800 (PST) (envelope-from nobody) Message-Id: <200403121524.i2CFOrUr083531@www.freebsd.org> Date: Fri, 12 Mar 2004 07:24:53 -0800 (PST) From: Claes M Nyberg To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Subject: misc/64164: Buffer overflow in /usr/bin/indent X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Mar 2004 15:30:23 -0000 >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: