summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-12-07 18:28:04 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-12-07 18:28:04 +0000
commit86312d159d55e99db5a5c82d9c50f31a1fe28199 (patch)
tree0f9f94e6c6d223df2f4beb3247c96e510ff0804d /src
parent2ddd93b4423b94578868e2701c265f8da4350965 (diff)
downloadskalibs-86312d159d55e99db5a5c82d9c50f31a1fe28199.tar.xz
Some trivial bugfixes and cleanups
Diffstat (limited to 'src')
-rw-r--r--src/libenvexec/xexecvep_loose.c2
-rw-r--r--src/libenvexec/xmexec0_af.c2
-rw-r--r--src/libstddjb/bitarray_clearsetn.c2
-rw-r--r--src/libstddjb/child_spawn1_internal.c2
-rw-r--r--src/libstddjb/fd_islocked.c1
-rw-r--r--src/libstddjb/fd_lock.c1
-rw-r--r--src/libstddjb/fd_unlock.c1
-rw-r--r--src/libunixonacid/ancil_recv_fd.c9
-rw-r--r--src/libunixonacid/ancil_send_fd.c2
9 files changed, 14 insertions, 8 deletions
diff --git a/src/libenvexec/xexecvep_loose.c b/src/libenvexec/xexecvep_loose.c
index a9935a6..ed2b3ee 100644
--- 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
index a0bf84d..29c4ea6 100644
--- 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
index fe97045..613a8a8 100644
--- 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
index 460bca0..6b3dc91 100644
--- 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
index bf9f9e8..8d5ef78 100644
--- 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
index 422e667..e9d1a62 100644
--- 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
index 4c63fd9..0e6ac0e 100644
--- 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
index 70f2c4f..5ecbb31 100644
--- 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
index 939d06c..5573d5c 100644
--- 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 ;