[hackers] [scc] Validate size of array declarations || Roberto E. Vargas Caballero
commit f071fe5eaccfa08807649ee69b8f8d7ee28a4505
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Aug 27 21:31:13 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Aug 27 21:31:13 2015 +0200
Validate size of array declarations
Array sizes must be possitive integers.
diff --git a/cc1/decl.c b/cc1/decl.c
index c92d546..b615c2f 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -105,7 +105,16 @@ arydcl(struct declarators *dp)
}
expect(']');
- n = (np == NULL) ? 0 : np->sym->u.i;
+ if (np != NULL) {
+ n = np->sym->u.i;
+ if (n == 0 || n < 0) {
+ errorp("array size is not a positive number");
+ n = 1;
+ }
+ } else {
+ n = 0;
+ }
+
freetree(np);
push(dp, ARY, n);
Received on Thu Aug 27 2015 - 21:33:55 CEST
This archive was generated by hypermail 2.3.0
: Thu Aug 27 2015 - 21:36:12 CEST