ref: 06ecbf0a8c425cef03cbd67cb818155738d759e0
parent: 1b93241842ebf1e5a7efaf62b1fcaf02a7c6d4e5
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Nov 24 12:01:34 EST 2017
[nm] Improve member skipping in ar() The condition to calculate the position in ar() was wrong and it was possible to fire an integer overflow.
--- a/nm/main.c
+++ b/nm/main.c
@@ -94,8 +94,17 @@
long pos;
while (rdarhdr(fp, &hdr) != EOF) {
- if ((pos = ftell(fp)) & 1)
+ pos = ftell(fp);
+ if (pos > LONG_MAX - hdr.size) {
+ fprintf(stderr,
+ "nm: %s: overflow in size of archive\n",
+ fname);
+ return;
+ }
+ pos += hdr.size;
+ if (hdr.size & 1)
++pos;
+
if (myrofile(fname, fp)) {
nm(fname, hdr.name, fp);
} else {