From 467bef5f6ad157d28f49a21e7e1b0e94c15ba92c Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sat, 10 Nov 2018 18:01:00 +0000 Subject: [PATCH] Check for overflow in int, not size_t. --- src/microcode/findprim.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/microcode/findprim.c b/src/microcode/findprim.c index f6a117725..f85f5e232 100644 --- a/src/microcode/findprim.c +++ b/src/microcode/findprim.c @@ -633,7 +633,7 @@ initialize_token_buffer (void) void grow_token_buffer (void) { - if (token_buffer_length >= (SIZE_MAX / 2)) + if (token_buffer_length >= (INT_MAX / 2)) { fprintf (stderr, "token buffer overflow\n"); exit (1); @@ -817,7 +817,7 @@ void grow_data_buffer (void) { char * old_data_buffer = ((char *) data_buffer); - if (buffer_length >= (SIZE_MAX / (2 * (sizeof (struct descriptor))))) + if (buffer_length >= (INT_MAX / (2 * (sizeof (struct descriptor))))) { fprintf (stderr, "data buffer overflow\n"); exit (1); @@ -837,7 +837,7 @@ grow_data_buffer (void) scan += 1; } } - if (buffer_length >= (SIZE_MAX / (sizeof (struct descriptor *)))) + if (buffer_length >= (INT_MAX / (sizeof (struct descriptor *)))) { fprintf (stderr, "result buffer overflow\n"); exit (1); -- 2.25.1