Skip to content

Commit

Permalink
fix: cover time import overflow corner case in wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-cristino committed Nov 7, 2024
1 parent d0d1a1c commit fc6c840
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/zen_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ ztime_t* time_arg(lua_State *L, int n) {
free(result);
lerror(L, "Could not read unix timestamp %s", arg);
return NULL;
} else if (l_result < INT_MIN || l_result > INT_MAX) {
free(result);
lerror(L, "Could not read unix timestamp %s out of range", arg);
return NULL;
} else {
char s_result[1024];
snprintf(s_result, 1024, "%ld", l_result);

Check warning on line 95 in src/zen_time.c

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] src/zen_time.c#L95

If you can, use sizeof(s_result) instead of 1024 as the 2nd arg to snprintf. [runtime/printf] [3]
Raw output
src/zen_time.c:95:  If you can, use sizeof(s_result) instead of 1024 as the 2nd arg to snprintf.  [runtime/printf] [3]

Check warning on line 95 in src/zen_time.c

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] src/zen_time.c#L95

Add #include <cstdio> for snprintf [build/include_what_you_use] [4]
Raw output
src/zen_time.c:95:  Add #include <cstdio> for snprintf  [build/include_what_you_use] [4]
if (l_result < INT_MIN || l_result > INT_MAX || strcmp(s_result, arg) != 0 ) {
free(result);
lerror(L, "Could not read unix timestamp %s out of range", arg);
return NULL;
}
}
*result = (ztime_t)l_result;
goto end;
Expand Down

0 comments on commit fc6c840

Please sign in to comment.