shithub: scc

Download patch

ref: 8e4d55811b9f52d2f8439a2507321f792c33b69f
parent: 663e1ef436aee781206c85d42fd304afb6272ba5
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Nov 28 03:32:14 EST 2017

[objdump] Remove size_t check of fields

These fields don't have any relation with size_t, so they
can be used with offset_t directly.

--- a/objdump/main.c
+++ b/objdump/main.c
@@ -73,7 +73,7 @@
 static int
 printsections(struct myrohdr *hdr, FILE *fp)
 {
-	size_t n, i;
+	unsigned long long n, i;
 	struct myrosect sect;
 
 	puts("sections:");
@@ -100,7 +100,7 @@
 static int
 printsymbols(struct myrohdr *hdr, FILE *fp)
 {
-	size_t n, i;
+	unsigned long long n, i;
 	struct myrosym sym;
 
 	puts("symbols:");
@@ -127,7 +127,7 @@
 static int
 printrelocs(struct myrohdr *hdr, FILE *fp)
 {
-	size_t n, i;
+	unsigned long long n, i;
 	struct myrorel rel;
 
 	puts("relocs:");
@@ -192,11 +192,11 @@
 			goto wrong_file;
 		if (rdmyrohdr(fp, &hdr) < 0)
 			goto wrong_file;
-		if (hdr.strsize > SIZE_MAX ||
-		    hdr.secsize > SIZE_MAX / MYROSECT_SIZ ||
-		    hdr.symsize > SIZE_MAX / MYROSYM_SIZ  ||
-		    hdr.relsize > SIZE_MAX / MYROREL_SIZ) {
-			goto overflow;
+		if (hdr.strsize > SIZE_MAX) {
+			fprintf(stderr,
+				"objdump: %s: overflow in header\n",
+				*argv, strerror(errno));
+				goto close_file;
 		}
 		strsiz = hdr.strsize;
 
@@ -224,13 +224,6 @@
 		fprintf(stderr,
 			"objdump: %s: %s\n",
 			*argv, strerror(errno));
-		goto close_file;
-
-overflow:
-		fprintf(stderr,
-			"objdump: %s: overflow in header\n",
-			*argv, strerror(errno));
-
 close_file:
 		if (fp)
 			fclose(fp);