]> git.ipfire.org Git - thirdparty/lldpd.git/blobdiff - src/ctl.c
fixedpoint: fix buffer overflow in fixed point computations
[thirdparty/lldpd.git] / src / ctl.c
index fd6d50d5772c3275ede081c0f2321cf6e3da2006..a347908eaf5e429a1e5fcd71a8ecc5842ef06543 100644 (file)
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -46,6 +46,10 @@ ctl_create(const char *name)
 
        if ((s = socket(PF_UNIX, SOCK_STREAM, 0)) == -1)
                return -1;
+       if (fcntl(s, F_SETFD, FD_CLOEXEC) == -1) {
+               close(s);
+               return -1;
+       }
        su.sun_family = AF_UNIX;
        strlcpy(su.sun_path, name, sizeof(su.sun_path));
        if (bind(s, (struct sockaddr *)&su, sizeof(struct sockaddr_un)) == -1) {
@@ -156,10 +160,10 @@ ctl_msg_send_unserialized(uint8_t **output_buffer, size_t *output_len,
                *output_buffer = new;
        }
 
-       struct hmsg_header hdr = {
-               .type = type,
-               .len = len
-       };
+       struct hmsg_header hdr;
+       memset(&hdr, 0, sizeof(struct hmsg_header));
+       hdr.type = type;
+       hdr.len = len;
        memcpy(*output_buffer + *output_len, &hdr, sizeof(struct hmsg_header));
        if (t)
                memcpy(*output_buffer + *output_len + sizeof(struct hmsg_header), buffer, len);