shithub: scc

Download patch

ref: 068af381fcb0e5b312fbc0c6da9ae1115f91b7c9
parent: 81b6d6367c1c9c957ca910e5f8b5fb70adfa9c21
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Nov 27 14:26:54 EST 2017

[lib/scc] Fix read myro header

--- a/lib/scc/lunpack.c
+++ b/lib/scc/lunpack.c
@@ -53,5 +53,5 @@
 	}
 	va_end(va);
 
-	return src - bp;
+	return bp - src;
 }
--- a/lib/scc/rmyro.c
+++ b/lib/scc/rmyro.c
@@ -16,8 +16,9 @@
 	fread(buf, sizeof(buf), 1, fp);
 	if (ferror(fp))
 		return EOF;
-	strncpy(hdr->magic, buf, MYROMAGIC_SIZ);
-	len = lunpack(buf + MYROMAGIC_SIZ, "lqqqqq",
+	len = lunpack(buf, "cccclqqqqq",
+	              hdr->magic+0, hdr->magic+1,
+	              hdr->magic+2, hdr->magic+3,
 	              &hdr->format,
 	              &hdr->entry,
 	              &hdr->strsize,
@@ -24,7 +25,6 @@
 	              &hdr->secsize,
 	              &hdr->symsize,
 	              &hdr->relsize);
-	len += MYROMAGIC_SIZ;
 	assert(len == MYROHDR_SIZ);
 
 	return len;