shithub: scc

Download patch

ref: 714e6c85055b439081e40823009a52bea7d98579
parent: 6284570962706a28b1bf7a45a59dad2261b49008
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sat Oct 30 01:49:29 EDT 2021

libmach/coff32: Use int for index in coff32getsym()

The prototype of getsym() includes an integer pointer
for the index. Several binary formats use bigger data
types for indexes, but in practical cases having a bigger
value does not work because it would require too much
memory to have the full symbol table in memory. Coff32
was converting the index value into long, because the
index value used by coff32 has long type, but it does
not make sense because it will not increase the range
already limited by the prototype of the function.

--- a/src/libmach/coff32/coff32getsym.c
+++ b/src/libmach/coff32/coff32getsym.c
@@ -55,7 +55,7 @@
 Symbol *
 coff32getsym(Obj *obj, int *idx, Symbol *sym)
 {
-	long n = *idx;
+	int n = *idx;
 	SYMENT *ent;
 	Coff32 *coff = obj->data;
 	FILHDR *hdr = &coff->hdr;