1
0
mirror of https://github.com/janet-lang/janet synced 2025-05-11 03:44:11 +00:00

Try to fix cfun registry size check for cross-thread messages

This commit is contained in:
Agent Kilo 2025-04-28 17:00:23 +08:00
parent f2eaa5dee8
commit a695454dae

View File

@ -3015,7 +3015,8 @@ static JanetEVGenericMessage janet_go_thread_subr(JanetEVGenericMessage args) {
uint32_t count1;
memcpy(&count1, nextbytes, sizeof(count1));
size_t count = (size_t) count1;
if (count > (endbytes - nextbytes) * sizeof(JanetCFunRegistry)) {
/* Use division to avoid overflowing size_t */
if (count > (endbytes - nextbytes - sizeof(count1)) / sizeof(JanetCFunRegistry)) {
janet_panic("thread message invalid");
}
janet_vm.registry_count = count;