From dufault@hda.com  Fri Dec 16 18:40:43 1994
Received: from hda.com (hda.com [199.232.40.182]) by freefall.cdrom.com (8.6.8/8.6.6) with ESMTP id SAA06084 for <FreeBSD-gnats-submit@freebsd.org>; Fri, 16 Dec 1994 18:40:40 -0800
Received: (dufault@localhost) by hda.com (8.6.9/8.3) id VAA13476; Fri, 16 Dec 1994 21:43:05 -0500
Message-Id: <199412170243.VAA13476@hda.com>
Date: Fri, 16 Dec 1994 21:43:05 -0500
From: dufault@hda.com
Reply-To: dufault@hda.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: "ranlib" and "ar" broke for long lines
X-Send-Pr-Version: 3.2

>Number:         62
>Category:       bin
>Synopsis:       "ranlib" and "ar" broke for long lines
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    core (FreeBSD core team)
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 16 18:50:00 1994
>Closed-Date:    Fri Dec 16 22:05:35 PST 1994
>Last-Modified:
>Originator:     Peter &
>Release:        FreeBSD 2.1.0-Development i386
>Organization:
Peter Dufault               Real Time Machine Control and Simulation
HD Associates, Inc.         Voice: 508 433 6936
dufault@hda.com             Fax:   508 433 5267
++++ New e-mail address.  E-mail problems? Tell hdslip@iii.net
>Environment:

-current

>Description:

ranlib and ar are broken for odd length long names.

>How-To-Repeat:

Run this shell script:

#!/bin/csh
set A=123456789
set B=123456789ABCDEF
set C=123456789ABCDEFG

cp /dev/null ${A}.c ; cc -c ${A}.c
cp /dev/null ${B}.c ; cc -c ${B}.c
cp /dev/null ${C}.c ; cc -c ${C}.c

rm -f libok.a

ar cq libok.a ${A}.o ${B}.o ${C}.o
ranlib libok.a

rm -f ${A}.c ${A}.o
rm -f ${B}.c ${B}.o
rm -f ${C}.c ${C}.o

>Fix:

Apply these patches in usr.bin/ar:

*** archive.c.orig	Fri Dec 16 21:36:52 1994
--- archive.c	Fri Dec 16 21:30:56 1994
***************
*** 299,305 ****
  		error(cfp->rname);
  	}
  
! 	if (cfp->flags & RPAD && size & 1 && (nr = read(from, buf, 1)) != 1) {
  		if (nr == 0)
  			badfmt();
  		error(cfp->rname);
--- 299,306 ----
  		error(cfp->rname);
  	}
  
! 	if (cfp->flags & RPAD && (size + chdr.lname) & 1 &&
! 	(nr = read(from, buf, 1)) != 1) {
  		if (nr == 0)
  			badfmt();
  		error(cfp->rname);
*** misc.c.orig	Fri May 27 08:30:49 1994
--- misc.c	Fri Dec 16 06:30:08 1994
***************
*** 126,135 ****
  compare(dest)
  	char *dest;
  {
! 
! 	if (options & AR_TR)
! 		return (!strncmp(chdr.name, rname(dest), OLDARMAXNAME));
! 	return (!strcmp(chdr.name, rname(dest)));
  }
  
  void
--- 126,133 ----
  compare(dest)
  	char *dest;
  {
! 	int maxname = (options & AR_TR) ? OLDARMAXNAME : MAXNAMLEN;
! 	return (!strncmp(chdr.name, rname(dest), maxname));
  }
  
  void
	

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: ache 
State-Changed-When: Fri Dec 16 22:05:35 PST 1994 
State-Changed-Why:  
Fixed. 
>Unformatted:



