shithub: scc

Download patch

ref: 0f2cb2792bc4b51ec4bd7ea4d90a6e572bd78860
parent: d72d86eb7ab39320fcd33642458862aff84bdc3b
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue May 12 06:35:57 EDT 2015

Add additional @ in defines

We need something that limits the numeric arrays,
because in other case we depend of the user trying
to do fancy things to get a segmentation fault.

--- a/cc1/cpp.c
+++ b/cc1/cpp.c
@@ -69,7 +69,7 @@
 {
 	unsigned ncopy, n;
 	size_t len;
-	char arroba[5], *par, *endp, **bp;
+	char arroba[6], *par, *endp, **bp;
 
 	while (*s && bufsiz > 0) {
 		if (!isalnum(*s) && *s != '_') {
@@ -86,13 +86,13 @@
 		for (bp =args, n = 0; n < nargs; ++bp, n++) {
 			if (strncmp(s, *bp, len))
 				continue;
-			sprintf(arroba, "@%02d", n);
+			sprintf(arroba, "@%02d@", n);
 			break;
 		}
 		if (n == nargs)
 			par = s, ncopy = len;
 		else
-			par = arroba, ncopy = 3;
+			par = arroba, ncopy = 4;
 
 		if ((bufsiz -= ncopy) < 0)
 			goto too_long;