diff options
author | deraadt <> | 2019-06-28 13:35:02 +0000 |
---|---|---|
committer | deraadt <> | 2019-06-28 13:35:02 +0000 |
commit | 6585927e66d9ab172754d95c4296dd4309a40512 (patch) | |
tree | bc969c069c7b769f2601db17f08bec99274202a5 /src/lib/libc/net/rresvport.c | |
parent | 74ff76124ba7a371400a9f60d5e33192a3732f03 (diff) | |
download | openbsd-6585927e66d9ab172754d95c4296dd4309a40512.tar.gz openbsd-6585927e66d9ab172754d95c4296dd4309a40512.tar.bz2 openbsd-6585927e66d9ab172754d95c4296dd4309a40512.zip |
When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.
Diffstat (limited to 'src/lib/libc/net/rresvport.c')
-rw-r--r-- | src/lib/libc/net/rresvport.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/libc/net/rresvport.c b/src/lib/libc/net/rresvport.c index 6b45000f7b..72c27c3a3f 100644 --- a/src/lib/libc/net/rresvport.c +++ b/src/lib/libc/net/rresvport.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: rresvport.c,v 1.11 2015/09/12 14:56:50 guenther Exp $ */ | 1 | /* $OpenBSD: rresvport.c,v 1.12 2019/06/28 13:32:42 deraadt Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 1995, 1996, 1998 Theo de Raadt. All rights reserved. | 3 | * Copyright (c) 1995, 1996, 1998 Theo de Raadt. All rights reserved. |
4 | * Copyright (c) 1983, 1993, 1994 | 4 | * Copyright (c) 1983, 1993, 1994 |
@@ -82,12 +82,12 @@ rresvport_af(int *alport, int af) | |||
82 | sa->sa_family = af; | 82 | sa->sa_family = af; |
83 | 83 | ||
84 | s = socket(af, SOCK_STREAM, 0); | 84 | s = socket(af, SOCK_STREAM, 0); |
85 | if (s < 0) | 85 | if (s == -1) |
86 | return (-1); | 86 | return (-1); |
87 | 87 | ||
88 | *portp = htons(*alport); | 88 | *portp = htons(*alport); |
89 | if (*alport < IPPORT_RESERVED - 1) { | 89 | if (*alport < IPPORT_RESERVED - 1) { |
90 | if (bind(s, sa, sa->sa_len) >= 0) | 90 | if (bind(s, sa, sa->sa_len) != -1) |
91 | return (s); | 91 | return (s); |
92 | if (errno != EADDRINUSE) { | 92 | if (errno != EADDRINUSE) { |
93 | (void)close(s); | 93 | (void)close(s); |