@@ -1226,6 +1226,11 @@ u64 parse_size(char *s)
char c;
u64 mult = 1;
+ if( len <= 0 ){
+ fprintf(stderr, "ERROR: size value is empty\n");
+ exit(50);
+ }
+
if (!isdigit(s[len - 1])) {
c = tolower(s[len - 1]);
switch (c) {
@@ -1242,6 +1247,13 @@ u64 parse_size(char *s)
exit(1);
}
s[len - 1] = '\0';
+ len--;
+ }
+ if( len > 0 && !isdigit(s[len - 1])) {
+ fprintf(stderr, "ERROR: Illegal size value contains "
+ "non-digit character %c in wrong position\n",
+ s[len-1]);
+ exit(51);
}
return strtoull(s, NULL, 0) * mult;
}
From: Goffredo Baroncelli <kreijack@inwind.it> Check that the suffix for the parse_size() input is of only one character. --- utils.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)