From owner-freebsd-bugs Sat Jan 2 19:50:09 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id TAA08034 for freebsd-bugs-outgoing; Sat, 2 Jan 1999 19:50:09 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id TAA08026 for ; Sat, 2 Jan 1999 19:50:08 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id TAA07240; Sat, 2 Jan 1999 19:50:01 -0800 (PST) Received: from rmstar.campus.luth.se (rmstar.campus.luth.se [130.240.197.32]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id TAA07660 for ; Sat, 2 Jan 1999 19:47:11 -0800 (PST) (envelope-from murduth@rmstar.campus.luth.se) Received: (from root@localhost) by rmstar.campus.luth.se (8.9.1/8.9.1) id EAA41959; Sun, 3 Jan 1999 04:46:40 +0100 (CET) (envelope-from murduth) Message-Id: <199901030346.EAA41959@rmstar.campus.luth.se> Date: Sun, 3 Jan 1999 04:46:40 +0100 (CET) From: murduth@ludd.luth.se Reply-To: murduth@ludd.luth.se To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/9281: [PATCH] awk uses junk memory Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 9281 >Category: bin >Synopsis: awk asumes memory that is returned from malloc is clean. >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: Sat Jan 2 19:50:00 PST 1999 >Last-Modified: >Originator: Joakim Henriksson >Organization: FreeBSD >Release: FreeBSD-CURRENT >Environment: /usr/src/contrib/awk/awk.y version 1.1.1.1 >Description: When repporting errors (and problably other places i havn't found/looked for) awk puts out garbage due to non null memory from malloc. >How-To-Repeat: cd /etc ; ln -s malloc.conf AJ cd ; cat > test.awk /foo/{ {if (FNR==2) foo = $0} ^D awk -f test.awk >Fix: Apply following patch in /usr/src. *** contrib/awk/awk.y.orig Sun Jan 3 03:54:24 1999 --- contrib/awk/awk.y Sun Jan 3 04:29:59 1999 *************** *** 1091,1096 **** --- 1091,1097 ---- } len = lexptr - scan; emalloc(buf, char *, len+1, "get_src_buf"); + bzero(buf, len + 1); memcpy(buf, scan, len); thisline = buf; lexptr = buf + len; *************** *** 1130,1136 **** newfile = TRUE; if (buf != NULL) free(buf); ! emalloc(buf, char *, len + SLOP, "get_src_buf"); lexptr_begin = buf + SLOP; samefile = TRUE; sourceline = 1; --- 1131,1138 ---- newfile = TRUE; if (buf != NULL) free(buf); ! emalloc(buf, char *, len + SLOP + 1, "get_src_buf"); ! bzero(buf, len + SLOP + 1); lexptr_begin = buf + SLOP; samefile = TRUE; sourceline = 1; >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message