1
Fork 0
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:
Gunnar Beutner 2021-04-12 16:44:04 +02:00 committed by Andreas Kling
parent bffa1a0df8
commit 287a93a2a4

View file

@ -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;