mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 23:58:11 +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
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