Fix stack buffer overflow in Schedule_Weekly_Schedule_Set (#1222)
* Fix stack buffer overflow in Schedule_Weekly_Schedule_Set The memcpy was using sizeof(BACNET_WEEKLY_SCHEDULE) instead of sizeof(BACNET_DAILY_SCHEDULE), causing it to read 6784 bytes from a 968-byte source buffer, leading to stack buffer overflow and segmentation fault in the test_schedule unit test. This fixes the test_schedule test failure detected by ASAN: ERROR: AddressSanitizer: stack-buffer-overflow on address ... READ of size 6784 at 0x... partially underflows this variable Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Update src/bacnet/basic/object/schedule.c Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: kent.liu <kent.liu@designlibro.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Steve Karg <steve@kargs.net> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -308,7 +308,7 @@ bool Schedule_Weekly_Schedule_Set(
|
||||
if (pObject && (array_index < BACNET_WEEKLY_SCHEDULE_SIZE)) {
|
||||
memcpy(
|
||||
&pObject->Weekly_Schedule[array_index], value,
|
||||
sizeof(BACNET_WEEKLY_SCHEDULE));
|
||||
sizeof(pObject->Weekly_Schedule[array_index]));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user