home: hub: 9ficl

Download patch

ref: f781811f92fa6886aaab7feb1fbc5911191dbad9
parent: 81445b33d65b39982d9e6e840930dd9fcfae4458
author: asau <asau@ficl.sf.net>
date: Mon Oct 25 15:51:56 CDT 2010

Fix potential problem with wide integers: buffer may overflow,
or the output may take more than 8 positions.

--- a/softcore/makesoftcore.c
+++ b/softcore/makesoftcore.c
@@ -26,10 +26,8 @@
 		fprintf(f, "\t");
 		for (i = 0; (i < 8) && length; i++)
 			{
-			char buf[16];
 			/* if you don't do this little stuff, you get ugly sign-extended 0xFFFFFF6b crap. */
-			sprintf(buf, "%08x", (unsigned int)*data++);
-			fprintf(f, "0x%s, ", buf + 6);
+			fprintf(f, "0x%02x, ", (unsigned)*(unsigned char*)data++);
 			length--;
 			}
 		fprintf(f, "\n");