Skip to content

Commit

Permalink
rest_client: Remove extra check
Browse files Browse the repository at this point in the history
Since "size_t" is an unsigned integer type, the RHS multiplication
result cannot be negative unless an overflow occurs when assigning to
LHS.  So we change the type of "len" to unsigned as well, to prevent
this corner-case.
  • Loading branch information
liviuchircu committed Nov 17, 2021
1 parent 2825caa commit fb8fbaf
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions modules/rest_client/rest_cb.c
Expand Up @@ -37,7 +37,7 @@
*/
size_t write_func(char *ptr, size_t size, size_t nmemb, void *body)
{
int len = size * nmemb;
unsigned int len = size * nmemb;
str *buff = (str *)body;

#ifdef EXTRA_DEBUG
Expand All @@ -47,9 +47,6 @@ size_t write_func(char *ptr, size_t size, size_t nmemb, void *body)
if (len == 0)
return 0;

if (len < 0)
len = strlen(ptr);

buff->s = pkg_realloc(buff->s, buff->len + len + 1);
if (!buff->s) {
buff->len = 0;
Expand Down

0 comments on commit fb8fbaf

Please sign in to comment.