Fix types.

ftell() returns a long; assign its value to a variable of that type.
size_t is unsigned, so checking that it's >= 0 always succeeds.

We can cast the variable's value to size_t once we've determined that it's
non-negative; do so, to avoid other warnings.

Change-Id: I0da6a220ce140ebf073df5f5bcd0c9526bf9c3c3
Reviewed-on: https://code.wireshark.org/review/24817
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2017-12-13 18:44:17 -08:00
parent 6d30df0cdd
commit 7539469d79
1 changed files with 3 additions and 3 deletions

View File

@ -128,12 +128,12 @@ int main(int argc, char **argv) {
FILE *f = ws_fopen(argv[i], "r");
assert(f);
fseek(f, 0, SEEK_END);
size_t len = ftell(f);
long len = ftell(f);
assert(len >= 0);
fseek(f, 0, SEEK_SET);
unsigned char *buf = (unsigned char*)g_malloc(len);
unsigned char *buf = (unsigned char*)g_malloc((size_t)len);
size_t n_read = fread(buf, 1, len, f);
assert(n_read == len);
assert(n_read == (size_t)len);
fclose(f);
LLVMFuzzerTestOneInput(buf, len);
g_free(buf);