NetBSD Problem Report #149
From gnats Wed Mar 2 18:33:58 1994
Received: from forte (forte.mathematik.uni-Bremen.de [134.102.232.1]) by sun-lamp.cs.berkeley.edu (8.6.5/8.6.5) with ESMTP id SAA07446 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Wed, 2 Mar 1994 18:33:53 -0800
Message-Id: <199403030233.DAA05437@forte>
Date: Thu, 3 Mar 1994 03:33:33 +0100
From: thomas@mathematik.uni-Bremen.de
Reply-To: thomas@mathematik.uni-Bremen.de
To: gnats-bugs@sun-lamp.cs.berkeley.edu
Subject: ranlib(1) trashes archives when given more than one
X-Send-Pr-Version: 3.2
>Number: 149
>Category: bin
>Synopsis: ranlib(1) trashes archives when given more than one
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: gnats-admin
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Mar 02 18:35:01 +0000 1994
>Closed-Date: Thu Mar 03 22:08:47 +0000 1994
>Last-Modified: Sun Mar 03 17:47:19 +0000 2013
>Originator: Thomas Eberhardt
>Release:
>Organization:
CeVis, University of Bremen, Germany
>Environment:
System: NetBSD ed209 0.9a ED209#0 i386
Machine: i386
>Description:
ranlib goes crazy after processing the first library because it
doesn't reset some vital variables. It also consumes more and more
memory since it also doesn't release the symbol table it built up.
And the temporary file names it generates when the TMPDIR environment
variable is set are bogus after the first archive. Also, it doesn't
close the archives when using "-t".
>How-To-Repeat:
ranlib liba.a libb.a
libb.a is trashed.
>Fix:
*** build.c- Fri Dec 17 08:16:34 1993
--- build.c Thu Mar 3 03:12:44 1994
***************
*** 63,68 ****
--- 63,71 ----
} RLIB;
RLIB *rhead, **pnext;
+ long symcnt; /* symbol count */
+ long tsymlen; /* total string length */
+
FILE *fp;
static void rexec(), symobj();
***************
*** 79,84 ****
--- 82,88 ----
SETCF(afd, archive, tfd, tname, RPAD|WPAD);
/* Read through the archive, creating list of symbols. */
+ symcnt = tsymlen = 0;
pnext = &rhead;
while(get_arobj(afd)) {
if (!strcmp(chdr.name, RANLIBMAG)) {
***************
*** 107,115 ****
return(0);
}
- long symcnt; /* symbol count */
- long tsymlen; /* total string length */
-
/*
* rexec
* Read the exec structure; ignore any files that don't look
--- 111,116 ----
***************
*** 216,222 ****
static void
symobj()
{
! register RLIB *rp;
struct ranlib rn;
char hb[sizeof(struct ar_hdr) + 1], pad;
long ransize, size, stroff;
--- 217,223 ----
static void
symobj()
{
! register RLIB *rp, *rnext;
struct ranlib rn;
char hb[sizeof(struct ar_hdr) + 1], pad;
long ransize, size, stroff;
***************
*** 269,277 ****
error(tname);
/* Write out the string table. */
! for (rp = rhead; rp; rp = rp->next)
if (!fwrite(rp->sym, rp->symlen, 1, fp))
error(tname);
if (pad && !fwrite(&pad, sizeof(pad), 1, fp))
error(tname);
--- 270,282 ----
error(tname);
/* Write out the string table. */
! for (rp = rhead; rp; rp = rnext) {
if (!fwrite(rp->sym, rp->symlen, 1, fp))
error(tname);
+ rnext = rp->next;
+ free(rp);
+ }
+ rhead = NULL;
if (pad && !fwrite(&pad, sizeof(pad), 1, fp))
error(tname);
*** misc.c- Tue Jan 4 12:37:02 1994
--- misc.c Thu Mar 3 02:50:24 1994
***************
*** 53,59 ****
tmp()
{
! char *envtmp;
sigset_t set, oset;
static int first;
int fd;
--- 53,59 ----
tmp()
{
! static char *envtmp = NULL;
sigset_t set, oset;
static int first;
int fd;
*** touch.c- Fri Dec 17 08:16:38 1993
--- touch.c Thu Mar 3 02:49:21 1994
***************
*** 66,71 ****
--- 66,72 ----
return(1);
}
settime(afd);
+ close_archive(afd);
return(0);
}
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: mycroft
State-Changed-When: Thu Mar 3 14:08:47 PST 1994
State-Changed-Why:
Supplied patch committed by Paul Kranenburg.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.