From murduth@rmstar.campus.luth.se  Fri Sep 18 13:08:22 1998
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 NAA21941
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 18 Sep 1998 13:08:01 -0700 (PDT)
          (envelope-from murduth@rmstar.campus.luth.se)
Received: (from root@localhost)
	by rmstar.campus.luth.se (8.9.1/8.9.1) id WAA07980;
	Fri, 18 Sep 1998 22:07:33 +0200 (CEST)
	(envelope-from murduth)
Message-Id: <199809182007.WAA07980@rmstar.campus.luth.se>
Date: Fri, 18 Sep 1998 22:07:33 +0200 (CEST)
From: Joakim Henriksson <murduth@ludd.luth.se>
Reply-To: murduth@ludd.luth.se
To: FreeBSD-gnats-submit@freebsd.org
Subject: New ld buggy!
X-Send-Pr-Version: 3.2

>Number:         7980
>Category:       bin
>Synopsis:       ld has some serious memory bugs.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 18 13:10:00 PDT 1998
>Closed-Date:    Sat Sep 19 15:33:46 PDT 1998
>Last-Modified:  Sat Sep 19 15:35:07 PDT 1998
>Originator:     Joakim Henriksson
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
University of Lule
>Environment:

uname -a
FreeBSD rmstar.campus.luth.se 3.0-CURRENT FreeBSD 3.0-CURRENT #2: Fri Sep 18 16:31:39 CEST 1998     murduth@rmstar.campus.luth.se:/usr/src/sys/compile/RMSTAR  i386

Current as of yesterday, ELF.

>Description:

Many arrays are assumed to be zero which breaks linking on lots of
different things.

>How-To-Repeat:

ln -s AJ /etc/malloc.conf
cat > breakld.c
#include <stdio.h>
#include <stlib.h>

void main(void){
  char *ptr;
  ptr = (char *) malloc(1024);
  gets(ptr);
}
^D
cc -c breakld.c
ld -o breakld breakld.o -lc

>Fix:
	
bzero() all allocated memory or at least don't asume that allocated memory is
zero'd, and add \000 where applicable.
>Release-Note:
>Audit-Trail:

From: Doug Rabson <dfr@nlsystems.com>
To: Joakim Henriksson <murduth@ludd.luth.se>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/7980: New ld buggy!
Date: Sat, 19 Sep 1998 14:40:39 +0100 (BST)

 Please try this patch to src/contrib/binutils/bfd which at least fixes the
 test case in the bug report:
 
 Index: elflink.h
 ===================================================================
 RCS file: /home/ncvs/src/contrib/binutils/bfd/elflink.h,v
 retrieving revision 1.1.1.2
 diff -u -r1.1.1.2 elflink.h
 --- elflink.h	1998/09/06 22:57:08	1.1.1.2
 +++ elflink.h	1998/09/19 10:18:46
 @@ -719,12 +719,14 @@
  		}
  
  	      sz = bfd_section_size (abfd, s);
 -	      msg = (char *) bfd_alloc (abfd, sz);
 +	      msg = (char *) bfd_alloc (abfd, sz+1);
  	      if (msg == NULL)
  		goto error_return;
  
  	      if (! bfd_get_section_contents (abfd, s, msg, (file_ptr) 0, sz))
  		goto error_return;
 +
 +	      msg[sz] = '\0';
  
  	      if (! (_bfd_generic_link_add_one_symbol
  		     (info, abfd, name, BSF_WARNING, s, (bfd_vma) 0, msg,
 
 --
 Doug Rabson				Mail:  dfr@nlsystems.com
 Nonlinear Systems Ltd.			Phone: +44 181 951 1891
 					Fax:   +44 181 381 1039
 
State-Changed-From-To: open->closed 
State-Changed-By: jdp 
State-Changed-When: Sat Sep 19 15:33:46 PDT 1998 
State-Changed-Why:  
Fixed by Doug Rabson's patch, in src/contrib/binutils/bfd/elflink.h 
revision 1.2. 
>Unformatted:
