mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-25 10:48:53 +00:00
DHCPClient: Fix undefined behaviour when calling memcpy() (#6416)
Calling memcpy with null pointers results in undefined behaviour, even if count is zero. This in turns is exploited by GCC. For example, the following code: memcpy (dst, src, n); if (!src) return; src[0] = 0xcafe; will be optimized as: memcpy (dst, src, n); src[0] = 0xcafe; IOW the test for NULL is gone.
This commit is contained in:
parent
eedde500eb
commit
f8c2beec7c
Notes:
sideshowbarker
2024-07-18 19:30:13 +09:00
Author: https://github.com/jubnzv 🔰
Commit: f8c2beec7c
Pull-request: https://github.com/SerenityOS/serenity/pull/6416
1 changed files with 2 additions and 1 deletions
|
@ -277,7 +277,8 @@ public:
|
|||
options[next_option_offset++] = (u8)option;
|
||||
memcpy(options + next_option_offset, &length, 1);
|
||||
next_option_offset++;
|
||||
memcpy(options + next_option_offset, data, length);
|
||||
if (data && length)
|
||||
memcpy(options + next_option_offset, data, length);
|
||||
next_option_offset += length;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue