Stop using unsafe sprintf method.
ISSUE=308
Signed-off-by: Kenneth Russell
Author: David Kilzer
git-svn-id: https://angleproject.googlecode.com/svn/trunk@1052 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/preprocessor/atom.c b/src/compiler/preprocessor/atom.c
index a17c319..e79d80f 100644
--- a/src/compiler/preprocessor/atom.c
+++ b/src/compiler/preprocessor/atom.c
@@ -434,14 +434,14 @@
if (cpp->options.DumpAtomTable) {
int ii;
char str[200];
- sprintf(str, "*** Hash failed with more than %d collisions. Must increase hash table size. ***",
+ snprintf(str, sizeof(str), "*** Hash failed with more than %d collisions. Must increase hash table size. ***",
HASH_TABLE_MAX_COLLISIONS);
CPPShInfoLogMsg(str);
- sprintf(str, "*** New string \"%s\", hash=%04x, delta=%04x", s, collision[0], hashdelta);
+ snprintf(str, sizeof(str), "*** New string \"%s\", hash=%04x, delta=%04x", s, collision[0], hashdelta);
CPPShInfoLogMsg(str);
for (ii = 0; ii <= HASH_TABLE_MAX_COLLISIONS; ii++) {
- sprintf(str, "*** Collides on try %d at hash entry %04x with \"%s\"",
+ snprintf(str, sizeof(str), "*** Collides on try %d at hash entry %04x with \"%s\"",
ii + 1, collision[ii], GetAtomString(atable, atable->htable.entry[collision[ii]].value));
CPPShInfoLogMsg(str);
}
@@ -685,14 +685,14 @@
char str[200];
for (ii = 0; ii < atable->nextFree; ii++) {
- sprintf(str, "%d: \"%s\"", ii, &atable->stable.strings[atable->amap[ii]]);
+ snprintf(str, sizeof(str), "%d: \"%s\"", ii, &atable->stable.strings[atable->amap[ii]]);
CPPDebugLogMsg(str);
}
- sprintf(str, "Hash table: size=%d, entries=%d, collisions=",
+ snprintf(str, sizeof(str), "Hash table: size=%d, entries=%d, collisions=",
atable->htable.size, atable->htable.entries);
CPPDebugLogMsg(str);
for (ii = 0; ii < HASH_TABLE_MAX_COLLISIONS; ii++) {
- sprintf(str, " %d", atable->htable.counts[ii]);
+ snprintf(str, sizeof(str), " %d", atable->htable.counts[ii]);
CPPDebugLogMsg(str);
}