check-qdict: Fix possible crash

This warning is reported by cppcheck:

check-qdict.c:270: warning: scanf without field width limits can crash with huge input data

Fix it by limiting the field widths to 127 (both key and value take
127 characters + a terminating '\0' byte).

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
Stefan Weil 2011-01-21 22:50:30 +01:00 committed by Aurelien Jarno
parent 8da91fffea
commit 7464f0587b
1 changed files with 2 additions and 1 deletions

View File

@ -267,8 +267,9 @@ static QString *read_line(FILE *file, char *key)
{
char value[128];
if (fscanf(file, "%s%s", key, value) == EOF)
if (fscanf(file, "%127s%127s", key, value) == EOF) {
return NULL;
}
remove_dots(key);
return qstring_from_str(value);
}