diff options
| author | Mariusz Zaborski <oshogbo@FreeBSD.org> | 2021-01-16 11:55:42 +0000 |
|---|---|---|
| committer | Mariusz Zaborski <oshogbo@FreeBSD.org> | 2021-01-16 11:55:42 +0000 |
| commit | 6e8062c855d19d1cbbd65b6843449f22791c3a0a (patch) | |
| tree | cdb6d8e8e659464b636ea85518a25689e179381b /bin/cat | |
| parent | 8ca9ff4f28d2055741e423d1c7befe178b3d6faf (diff) | |
Diffstat (limited to 'bin/cat')
| -rw-r--r-- | bin/cat/cat.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/bin/cat/cat.c b/bin/cat/cat.c index cdfc983610de..8ba6f6261ad4 100644 --- a/bin/cat/cat.c +++ b/bin/cat/cat.c @@ -429,7 +429,7 @@ udom_open(const char *path, int flags) struct addrinfo hints, *res, *res0; char rpath[PATH_MAX]; int fd = -1; - int error; + int error, serrno; cap_rights_t rights; /* @@ -453,18 +453,23 @@ udom_open(const char *path, int flags) fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); if (fd < 0) { + serrno = errno; freeaddrinfo(res0); + errno = serrno; return (-1); } if (caph_rights_limit(fd, &rights) < 0) { + serrno = errno; close(fd); freeaddrinfo(res0); + errno = serrno; return (-1); } error = cap_connect(capnet, fd, res->ai_addr, res->ai_addrlen); if (error == 0) break; else { + serrno = errno; close(fd); fd = -1; } @@ -492,9 +497,13 @@ udom_open(const char *path, int flags) cap_rights_clear(&rights, CAP_CONNECT, CAP_SHUTDOWN); if (caph_rights_limit(fd, &rights) < 0) { + serrno = errno; close(fd); + errno = serrno; return (-1); } + } else { + errno = serrno; } return (fd); } |
