shithub: scc

Download patch

ref: 3b342595ee8598daefeb5cdf52e59aa29ddad468
parent: 248895ea200d3cc2865fea1e87265f196a0fe218
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Nov 28 03:54:57 EST 2017

[objdump] Validate the magic number of the object file

--- a/objdump/main.c
+++ b/objdump/main.c
@@ -189,6 +189,12 @@
 		goto wrong_file;
 	if (rdmyrohdr(fp, &hdr) < 0)
 		goto wrong_file;
+	if (strncmp(hdr.magic, MYROMAGIC, MYROMAGIC_SIZ)) {
+		fprintf(stderr,
+		        "objdump: %s: File format not recognized\n",
+		        fname);
+		goto close_file;
+	}
 	if (hdr.strsize > SIZE_MAX) {
 		fprintf(stderr,
 			"objdump: %s: overflow in header\n",