X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fsocket-util.c;h=e0f34e71409dec627e16f9938b5512f20534e662;hb=c38e3405d927ce999d59e837b82529552df8e168;hp=469131d4cf4ff8ae294281a1eb46aeb12ef2c606;hpb=d31f1109f10e5ffb9bf266306b913ebf23781666;p=openvswitch diff --git a/lib/socket-util.c b/lib/socket-util.c index 469131d4..e0f34e71 100644 --- a/lib/socket-util.c +++ b/lib/socket-util.c @@ -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); } @@ -270,6 +269,8 @@ make_sockaddr_un(const char *name, struct sockaddr_un *un, socklen_t *un_len, dirfd = open(dir, O_DIRECTORY | O_RDONLY); if (dirfd < 0) { + free(base); + free(dir); return errno; }