summaryrefslogtreecommitdiff
path: root/files.c
diff options
context:
space:
mode:
authorJagger <robert@swiecki.net>2016-09-22 04:04:34 +0200
committerJagger <robert@swiecki.net>2016-09-22 04:04:34 +0200
commitc64c9ebd12ed029c4af5b4ebd1343e7e68c09147 (patch)
treedc6b484316856510e5b4ec4203779b49f06be87c /files.c
parent18f680fa6a394c4078c4703cc8456a30ddc7c687 (diff)
downloadhonggfuzz-c64c9ebd12ed029c4af5b4ebd1343e7e68c09147.tar.gz
Don't use strlen() for dictionary entries
Diffstat (limited to 'files.c')
-rw-r--r--files.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/files.c b/files.c
index 09bdd4a8..423701ac 100644
--- a/files.c
+++ b/files.c
@@ -276,20 +276,22 @@ bool files_parseDictionary(honggfuzz_t * hfuzz)
for (;;) {
char *lineptr = NULL;
size_t n = 0;
- if (getdelim(&lineptr, &n, '\n', fDict) == -1) {
+ ssize_t len = getdelim(&lineptr, &n, '\n', fDict);
+ if (len == -1) {
break;
}
- size_t len = strlen(lineptr);
- if (len > 1 && lineptr[len - 1] == '\n') {
+ if (n > 1 && lineptr[len - 1] == '\n') {
lineptr[len - 1] = '\0';
+ len--;
}
struct strings_t *str = (struct strings_t *)util_Malloc(sizeof(struct strings_t));
str->s = util_decodeCString(lineptr);
+ str->len = len;
hfuzz->dictionaryCnt += 1;
TAILQ_INSERT_TAIL(&hfuzz->dictionaryq, str, pointers);
- LOG_D("Dictionary: loaded word: '%s' (len=%zu)", str->s, strlen(str->s));
+ LOG_D("Dictionary: loaded word: '%s' (len=%zu)", str->s, str->len);
}
LOG_I("Loaded %zu words from the dictionary", hfuzz->dictionaryCnt);
return true;