commit 86312d159d55e99db5a5c82d9c50f31a1fe28199
parent 2ddd93b4423b94578868e2701c265f8da4350965
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Mon, 7 Dec 2020 18:28:04 +0000
Some trivial bugfixes and cleanups
Diffstat:
9 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/libenvexec/xexecvep_loose.c b/src/libenvexec/xexecvep_loose.c
@@ -8,6 +8,6 @@
void xexecvep_loose (char const *file, char const *const *argv, char const *const *envp, char const *path)
{
- xexecvep_loose(file, argv, envp, path) ;
+ execvep_loose(file, argv, envp, path) ;
strerr_dieexec(errno == ENOENT ? 127 : 126, file) ;
}
diff --git a/src/libenvexec/xmexec0_af.c b/src/libenvexec/xmexec0_af.c
@@ -7,6 +7,6 @@
void xmexec0_af (char const *file, char const *const *argv, char const *const *envp, size_t envlen)
{
- xmexec0_af(file, argv, envp, envlen) ;
+ mexec0_af(file, argv, envp, envlen) ;
strerr_dieexec(errno == ENOENT ? 127 : 126, file) ;
}
diff --git a/src/libstddjb/bitarray_clearsetn.c b/src/libstddjb/bitarray_clearsetn.c
@@ -8,7 +8,7 @@ void bitarray_clearsetn (unsigned char *s, size_t a, size_t b, int h)
b += a ;
if ((a >> 3) == ((b-1) >> 3))
{
- unsigned char mask = (1 << (a & 7)) - 1 ^ (1 << 1 + (b-1 & 7)) - 1 ;
+ unsigned char mask = (1 << (a & 7)) - 1 ^ (1 << (1 + (b-1 & 7))) - 1 ;
if (h) s[a>>3] |= mask ; else s[a>>3] &= ~mask ;
}
else
diff --git a/src/libstddjb/child_spawn1_internal.c b/src/libstddjb/child_spawn1_internal.c
@@ -33,7 +33,7 @@ pid_t child_spawn1_internal (char const *prog, char const *const *argv, char con
}
e = posix_spawn_file_actions_init(&actions) ;
if (e) goto errattr ;
- if (p[to & 1] != to & 1)
+ if (p[to & 1] != (to & 1))
{
e = posix_spawn_file_actions_adddup2(&actions, p[to & 1], to & 1) ;
if (e) goto erractions ;
diff --git a/src/libstddjb/fd_islocked.c b/src/libstddjb/fd_islocked.c
@@ -1,6 +1,7 @@
/* ISC license. */
#include <fcntl.h>
+#include <unistd.h>
#include <skalibs/djbunix.h>
diff --git a/src/libstddjb/fd_lock.c b/src/libstddjb/fd_lock.c
@@ -1,6 +1,7 @@
/* ISC license. */
#include <fcntl.h>
+#include <unistd.h>
#include <errno.h>
#include <skalibs/error.h>
diff --git a/src/libstddjb/fd_unlock.c b/src/libstddjb/fd_unlock.c
@@ -1,6 +1,7 @@
/* ISC license. */
#include <fcntl.h>
+#include <unistd.h>
#include <errno.h>
#include <skalibs/djbunix.h>
diff --git a/src/libunixonacid/ancil_recv_fd.c b/src/libunixonacid/ancil_recv_fd.c
@@ -4,6 +4,7 @@
#include <skalibs/nonposix.h>
#include <errno.h>
+#include <string.h>
#include <sys/uio.h>
#include <sys/socket.h>
@@ -33,6 +34,7 @@ int ancil_recv_fd (int sock, char expected_ch)
0
#endif
;
+ int fd ;
struct cmsghdr *c ;
ssize_t r ;
char ch ;
@@ -58,12 +60,13 @@ int ancil_recv_fd (int sock, char expected_ch)
|| c->cmsg_level != SOL_SOCKET
|| c->cmsg_type != SCM_RIGHTS
|| (size_t)(c->cmsg_len - (CMSG_DATA(c) - (unsigned char *)c)) != sizeof(int)) return (errno = EPROTO, -1) ;
+ memcpy(&fd, CMSG_DATA(c), sizeof(int)) ;
#ifndef SKALIBS_HASCMSGCLOEXEC
- if (coe(*(int *)CMSG_DATA(c)) < 0)
+ if (coe(fd) < 0)
{
- fd_close(*(int *)CMSG_DATA(c)) ;
+ fd_close(fd) ;
return -1 ;
}
#endif
- return *(int *)CMSG_DATA(c) ;
+ return fd ;
}
diff --git a/src/libunixonacid/ancil_send_fd.c b/src/libunixonacid/ancil_send_fd.c
@@ -35,7 +35,7 @@ int ancil_send_fd (int sock, int fd, char ch)
c->cmsg_level = SOL_SOCKET ;
c->cmsg_type = SCM_RIGHTS ;
c->cmsg_len = CMSG_LEN(sizeof(int)) ;
- *(int *)CMSG_DATA(c) = fd ;
+ memcpy(CMSG_DATA(c), &fd, sizeof(int)) ;
do r = sendmsg(sock, &hdr, MSG_NOSIGNAL) ;
while (r < 0 && errno == EINTR) ;
if (r <= 0) return 0 ;