diff options
author | ache <ache@FreeBSD.org> | 1994-12-28 13:19:39 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1994-12-28 13:19:39 +0000 |
commit | 9c459c890666317c9f774e1883197294e5a5aded (patch) | |
tree | 187667fd5758b4516646b1a2a9d489399af8196d /usr.bin | |
parent | 46e9ddaf128a8b2699b8bbe1983cdc646dc450dd (diff) | |
download | FreeBSD-src-9c459c890666317c9f774e1883197294e5a5aded.zip FreeBSD-src-9c459c890666317c9f774e1883197294e5a5aded.tar.gz |
Additional longname fix
Submitted by: dufault@hda.com
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/nm/nm.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/usr.bin/nm/nm.c b/usr.bin/nm/nm.c index 542f8e0..b4bf1c8 100644 --- a/usr.bin/nm/nm.c +++ b/usr.bin/nm/nm.c @@ -211,9 +211,10 @@ show_archive(fname, fp) int i, rval; long last_ar_off; char *p, *name, *ar_name; - int buffend = strlen(fname) + 3; + int extra = strlen(fname) + 3; - name = emalloc(sizeof(MAXNAMLEN) + buffend); + name = emalloc(MAXNAMLEN + extra); + ar_name = name + extra; rval = 0; @@ -239,7 +240,6 @@ show_archive(fname, fp) */ if (!bcmp(ar_head.ar_name, AR_EFMT1, sizeof(AR_EFMT1) - 1)) { - char *end_part = name + buffend; size_t len = atoi(ar_head.ar_name + sizeof(AR_EFMT1) - 1); if (len <= 0 || len > MAXNAMLEN) @@ -247,22 +247,21 @@ show_archive(fname, fp) fprintf(stderr, "nm: Illegal length for format 1 long name.\n"); goto skip; } - if (fread(end_part, 1, len, fp) != len) + if (fread(ar_name, 1, len, fp) != len) { (void)fprintf(stderr, "nm: EOF reading format 1 long name.\n"); (void)free(name); return(1); } - end_part[len] = 0; - ar_name = end_part; + ar_name[len] = 0; } else { - p = ar_name = ar_head.ar_name; + p = ar_head.ar_name; for (i = 0; i < sizeof(ar_head.ar_name); i++) if (*p && *p != ' ') - p++; - *p = '\0'; + ar_name[i] = p[i]; + ar_name[i] = 0; } /* |