ref: 0e3916924910843d4edb4fa7795e8b9476ed9e54
parent: 4ddb383f2b1ea7f017404f94e9e2683af3bcc43f
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Feb 10 16:13:41 EST 2019
[ranlib] Fix merging index file
--- a/src/cmd/ranlib.c
+++ b/src/cmd/ranlib.c
@@ -211,6 +211,8 @@
index = namindex(artype);
if (!strncmp(first.ar_name, index, SARNAM))
fseek(lib, atol(first.ar_size), SEEK_CUR);
+ else
+ fseek(lib, SARMAG, SEEK_SET);
fwrite(ARMAG, SARMAG, 1, to);
@@ -226,6 +228,8 @@
while ((c = getc(idx)) != EOF)
putc(c, to);
+ if (prop->size & 1)
+ putc('\n', to);
while ((c = getc(lib)) != EOF)
putc(c, to);
--- a/src/libmach/coff32/coff32setidx.c
+++ b/src/libmach/coff32/coff32setidx.c
@@ -24,8 +24,8 @@
}
for (def = head; def; def = def->next) {
- len = strlen(def->name);
- fwrite(def->name, len+1, 1, fp);
+ len = strlen(def->name) + 1;
+ fwrite(def->name, len, 1, fp);
n += len;
}