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:
xiang33
2026-02-07 11:01:44 +08:00
committed by GitHub
parent 1d1cf9bfac
commit 741748f929
+1 -1
View File
@@ -308,7 +308,7 @@ bool Schedule_Weekly_Schedule_Set(
if (pObject && (array_index < BACNET_WEEKLY_SCHEDULE_SIZE)) { if (pObject && (array_index < BACNET_WEEKLY_SCHEDULE_SIZE)) {
memcpy( memcpy(
&pObject->Weekly_Schedule[array_index], value, &pObject->Weekly_Schedule[array_index], value,
sizeof(BACNET_WEEKLY_SCHEDULE)); sizeof(pObject->Weekly_Schedule[array_index]));
return true; return true;
} }