Fix suspicius code for allocating a sockaddr_un to a sockaddr ptr

Remarked on by Coverity Scan.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2019-11-13 08:14:48 +01:00
parent e1f9a1a566
commit 0555e0989f

View File

@ -77,10 +77,13 @@ int socket_register(int sd, struct addrinfo *ai, void (*cb)(int, void *), void *
goto err;
if (ai) {
entry->ai.ai_addr = calloc(1, sizeof(struct sockaddr_un));
if (!entry->ai.ai_addr)
struct sockaddr_un *sun;
sun = calloc(1, sizeof(struct sockaddr_un));
if (!sun)
goto eaddr;
entry->ai.ai_addr = (struct sockaddr *)sun;
entry->ai = *ai;
*entry->ai.ai_addr = *ai->ai_addr;
}