From: Daniel Wagner <[email protected]>

The socket creation can fail and should be checked. Also return
negative error codes as in the rest of the code base.

Reported by coverity.
---
 src/6to4.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/6to4.c b/src/6to4.c
index 463d2da..0e3a7a1 100644
--- a/src/6to4.c
+++ b/src/6to4.c
@@ -82,13 +82,15 @@ static int tunnel_create(struct in_addr *addr)
        strncpy(ifr.ifr_name, "sit0", sizeof(ifr.ifr_name) - 1);
        ifr.ifr_ifru.ifru_data = (void *)&p;
        fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+       if (fd < 0)
+               return -errno;
        ret = ioctl(fd, SIOCADDTUNNEL, &ifr);
        if (ret)
                connman_error("add tunnel %s failed: %s", ifr.ifr_name,
                                                        strerror(errno));
        close(fd);
 
-       return ret;
+       return -ret;
 }
 
 static void tunnel_destroy(void)
-- 
1.8.4.474.g128a96c

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to