mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:37:35 +00:00
LibC: Validate the len argument for inet_ntop()
This commit is contained in:
parent
bffa1a0df8
commit
287a93a2a4
1 changed files with 4 additions and 0 deletions
|
@ -37,6 +37,10 @@ const char* inet_ntop(int af, const void* src, char* dst, socklen_t len)
|
|||
errno = EAFNOSUPPORT;
|
||||
return nullptr;
|
||||
}
|
||||
if (len < 4) {
|
||||
errno = ENOSPC;
|
||||
return nullptr;
|
||||
}
|
||||
auto* bytes = (const unsigned char*)src;
|
||||
snprintf(dst, len, "%u.%u.%u.%u", bytes[0], bytes[1], bytes[2], bytes[3]);
|
||||
return (const char*)dst;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue