Skip to content

Commit

Permalink
LibC: Fix strncpy() overflow in gethostbyname()
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Apr 13, 2020
1 parent 038fdc2 commit c1607dc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Libraries/LibC/netdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ hostent* gethostbyname(const char* name)
if (rc <= 0)
return nullptr;

strncpy(__gethostbyname_name_buffer, name, strlen(name));
strncpy(__gethostbyname_name_buffer, name, sizeof(__gethostbyaddr_name_buffer) - 1);

__gethostbyname_buffer.h_name = __gethostbyname_name_buffer;
__gethostbyname_buffer.h_aliases = nullptr;
Expand Down

0 comments on commit c1607dc

Please sign in to comment.