mirror of
https://github.com/openvswitch/ovs
synced 2025-08-30 22:05:19 +00:00
util: New function ovs_strzcpy().
Static analyzers hate strncpy(). This new function shares its property of initializing an entire buffer, without its nasty habit of failing to null-terminate long strings. Coverity #10697,10696,10695,10694,10693,10692,10691,10690.
This commit is contained in:
@@ -233,8 +233,7 @@ static void
|
||||
make_sockaddr_un__(const char *name, struct sockaddr_un *un, socklen_t *un_len)
|
||||
{
|
||||
un->sun_family = AF_UNIX;
|
||||
strncpy(un->sun_path, name, sizeof un->sun_path);
|
||||
un->sun_path[sizeof un->sun_path - 1] = '\0';
|
||||
ovs_strzcpy(un->sun_path, name, sizeof un->sun_path);
|
||||
*un_len = (offsetof(struct sockaddr_un, sun_path)
|
||||
+ strlen (un->sun_path) + 1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user