Skip to content

Commit

Permalink
virtfs-proxy: Fix possible overflow
Browse files Browse the repository at this point in the history
It's detected by coverity. The socket name specified
should fit in the sockadd_un.sun_path. If not abort.

Signed-off-by: Shannon Zhao <[email protected]>
Signed-off-by: Shannon Zhao <[email protected]>
Signed-off-by: Aneesh Kumar K.V <[email protected]>
  • Loading branch information
Shannon Zhao authored and kvaneesh committed Mar 16, 2015
1 parent 821c447 commit 25ee9a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions fsdev/virtfs-proxy-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ static int proxy_socket(const char *path, uid_t uid, gid_t gid)
return -1;
}

g_assert(strlen(path) < sizeof(proxy.sun_path));
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
do_perror("socket");
Expand Down
4 changes: 4 additions & 0 deletions hw/9pfs/virtio-9p-proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,10 @@ static int connect_namedsocket(const char *path)
int sockfd, size;
struct sockaddr_un helper;

if (strlen(path) >= sizeof(helper.sun_path)) {
fprintf(stderr, "Socket name too large\n");
return -1;
}
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
if (sockfd < 0) {
fprintf(stderr, "failed to create socket: %s\n", strerror(errno));
Expand Down

0 comments on commit 25ee9a7

Please sign in to comment.