libc: fix warning in socket_fs_plugin.cc

By using Genode::strncpy instead of the libc's strncpy, we cannot end up
in the situation where the result lacks the zero termination (where the
number of charactors equals the destination buffer size).
This commit is contained in:
Norman Feske 2019-08-15 10:42:08 +02:00 committed by Christian Helmuth
parent 15b27a1e9d
commit fd8a209da2

View File

@ -357,7 +357,7 @@ struct Socket_fs::Sockaddr_string : String<NI_MAXHOST + NI_MAXSERV>
{ {
Host_string host; Host_string host;
strncpy(host.base(), base(), host.capacity()); Genode::strncpy(host.base(), base(), host.capacity());
char *at = strstr(host.base(), ":"); char *at = strstr(host.base(), ":");
if (!at) if (!at)
throw Address_conversion_failed(); throw Address_conversion_failed();
@ -374,7 +374,7 @@ struct Socket_fs::Sockaddr_string : String<NI_MAXHOST + NI_MAXSERV>
if (!at) if (!at)
throw Address_conversion_failed(); throw Address_conversion_failed();
strncpy(port.base(), ++at, port.capacity()); Genode::strncpy(port.base(), ++at, port.capacity());
return port; return port;
} }