diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2026-01-01 13:47:45 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2026-01-01 13:47:45 +0000 |
| commit | e99182dab3093f1645f9e4ff216aa752d7443fb1 (patch) | |
| tree | 175a373c32a58783edd41901d4baf6e68626c7ec /src/libunixonacid/ancil_recv_fd.c | |
| parent | 45137c6466050c9468931713a7504eae3d08bfce (diff) | |
| download | skalibs-e99182dab3093f1645f9e4ff216aa752d7443fb1.tar.gz | |
Save/restore errno in all safe wrappers
Diffstat (limited to 'src/libunixonacid/ancil_recv_fd.c')
| -rw-r--r-- | src/libunixonacid/ancil_recv_fd.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libunixonacid/ancil_recv_fd.c b/src/libunixonacid/ancil_recv_fd.c index 5ecbb31..0148a43 100644 --- a/src/libunixonacid/ancil_recv_fd.c +++ b/src/libunixonacid/ancil_recv_fd.c @@ -50,10 +50,12 @@ int ancil_recv_fd (int sock, char expected_ch) .msg_control = ancilbuf, .msg_controllen = CMSG_SPACE(sizeof(int)) } ; + int e = errno ; do r = recvmsg(sock, &msghdr, awesomeflags) ; while (r < 0 && errno == EINTR) ; if (r < 0) return r ; if (!r) return (errno = EPIPE, -1) ; + errno = e ; c = CMSG_FIRSTHDR(&msghdr) ; if (ch != expected_ch || !c @@ -62,7 +64,7 @@ int ancil_recv_fd (int sock, char expected_ch) || (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(fd) < 0) + if (coe(fd) == -1) { fd_close(fd) ; return -1 ; |
