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) {
*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);