summaryrefslogtreecommitdiffstats
path: root/sys/netinet/in_pcb.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2001-03-12 21:53:23 +0000
committerphk <phk@FreeBSD.org>2001-03-12 21:53:23 +0000
commit07e97d2a867658eb2c0e7c18963f3cab1e275c9a (patch)
tree5b698aa704e4742c6f34da3879a59ba969047a04 /sys/netinet/in_pcb.c
parent07f8080780b3d2c531c2235cf89fbab902452a3d (diff)
downloadFreeBSD-src-07e97d2a867658eb2c0e7c18963f3cab1e275c9a.zip
FreeBSD-src-07e97d2a867658eb2c0e7c18963f3cab1e275c9a.tar.gz
Correctly cleanup in case of failure to bind a pcb.
PR: 25751 Submitted by: <unicorn@Forest.Od.UA>
Diffstat (limited to 'sys/netinet/in_pcb.c')
-rw-r--r--sys/netinet/in_pcb.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 45c13a4..e783640 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -272,8 +272,10 @@ in_pcbbind(inp, nam, p)
int count;
if (inp->inp_laddr.s_addr != INADDR_ANY)
- if (prison_ip(p->p_ucred, 0, &inp->inp_laddr.s_addr ))
+ if (prison_ip(p->p_ucred, 0, &inp->inp_laddr.s_addr )) {
+ inp->inp_laddr.s_addr = INADDR_ANY;
return (EINVAL);
+ }
inp->inp_flags |= INP_ANONPORT;
if (inp->inp_flags & INP_HIGHPORT) {
@@ -281,8 +283,10 @@ in_pcbbind(inp, nam, p)
last = ipport_hilastauto;
lastport = &pcbinfo->lasthi;
} else if (inp->inp_flags & INP_LOWPORT) {
- if (p && (error = suser_xxx(0, p, PRISON_ROOT)))
+ if (p && (error = suser_xxx(0, p, PRISON_ROOT))) {
+ inp->inp_laddr.s_addr = INADDR_ANY;
return error;
+ }
first = ipport_lowfirstauto; /* 1023 */
last = ipport_lowlastauto; /* 600 */
lastport = &pcbinfo->lastlow;
@@ -306,10 +310,6 @@ in_pcbbind(inp, nam, p)
do {
if (count-- < 0) { /* completely used? */
- /*
- * Undo any address bind that may have
- * occurred above.
- */
inp->inp_laddr.s_addr = INADDR_ANY;
return (EADDRNOTAVAIL);
}
@@ -343,8 +343,11 @@ in_pcbbind(inp, nam, p)
}
}
inp->inp_lport = lport;
- if (prison_ip(p->p_ucred, 0, &inp->inp_laddr.s_addr))
+ if (prison_ip(p->p_ucred, 0, &inp->inp_laddr.s_addr)) {
+ inp->inp_laddr.s_addr = INADDR_ANY;
+ inp->inp_lport = 0;
return(EINVAL);
+ }
if (in_pcbinshash(inp) != 0) {
inp->inp_laddr.s_addr = INADDR_ANY;
inp->inp_lport = 0;
OpenPOWER on IntegriCloud