Skip to content

Commit 5236393

Browse files
authored
Merge pull request #1593 from agent-kilo/thread-message-size-check
Try to fix cfun registry size check for cross-thread messages
2 parents f2eaa5d + a695454 commit 5236393

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/core/ev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3015,7 +3015,8 @@ static JanetEVGenericMessage janet_go_thread_subr(JanetEVGenericMessage args) {
30153015
uint32_t count1;
30163016
memcpy(&count1, nextbytes, sizeof(count1));
30173017
size_t count = (size_t) count1;
3018-
if (count > (endbytes - nextbytes) * sizeof(JanetCFunRegistry)) {
3018+
/* Use division to avoid overflowing size_t */
3019+
if (count > (endbytes - nextbytes - sizeof(count1)) / sizeof(JanetCFunRegistry)) {
30193020
janet_panic("thread message invalid");
30203021
}
30213022
janet_vm.registry_count = count;

0 commit comments

Comments
 (0)