commit 6abf674372bf77c7bcd7ed762b3791c67b7fdf47
parent e9fd2f28fb1200643f668d500c1239a4154d0cb1
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Fri, 8 May 2026 18:44:35 +0200
ranlib: Fix detection of previous index
The strncmp was wrong because after the end of the member name
the ar format has spaces that are not going to match with the
end of string. Also, it didn't consider the padding of ar members
which has to be 2 bytes.
Diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/cmd/scc-ranlib.c b/src/cmd/scc-ranlib.c
@@ -237,10 +237,12 @@ merge(FILE *to, struct fprop *prop, FILE *lib, FILE *idx)
if (fread(&first, sizeof(first), 1, lib) != 1)
return;
- if (!strncmp(first.ar_name, namidx, SARNAM))
- fseek(lib, atol(first.ar_size), SEEK_CUR);
- else
+ if (!strncmp(first.ar_name, namidx, strlen(namidx))) {
+ long siz = atol(first.ar_size);
+ fseek(lib, siz + (siz & 1), SEEK_CUR);
+ } else {
fseek(lib, SARMAG, SEEK_SET);
+ }
fwrite(ARMAG, SARMAG, 1, to);