Page MenuHomeFreeBSD

D61010.1795216934.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D61010.1795216934.diff

diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -147,18 +147,26 @@
static int
sysctl_net_ipport_check(SYSCTL_HANDLER_ARGS)
{
+ u_int *var, port;
int error;
- error = sysctl_handle_int(oidp, arg1, arg2, req);
- if (error == 0) {
- RANGECHK(V_ipport_lowfirstauto, 1, IPPORT_RESERVED - 1);
- RANGECHK(V_ipport_lowlastauto, 1, IPPORT_RESERVED - 1);
- RANGECHK(V_ipport_firstauto, IPPORT_RESERVED, IPPORT_MAX);
- RANGECHK(V_ipport_lastauto, IPPORT_RESERVED, IPPORT_MAX);
- RANGECHK(V_ipport_hifirstauto, IPPORT_RESERVED, IPPORT_MAX);
- RANGECHK(V_ipport_hilastauto, IPPORT_RESERVED, IPPORT_MAX);
+ var = arg1;
+ port = *var;
+ error = sysctl_handle_int(oidp, &port, 0, req);
+ if (error != 0 || req->newptr == NULL)
+ return (error);
+ if (var == &V_ipport_lowfirstauto || var == &V_ipport_lowlastauto) {
+ RANGECHK(port, 1, IPPORT_RESERVED - 1);
+ } else {
+ RANGECHK(port, IPPORT_RESERVED, IPPORT_MAX);
}
- return (error);
+ if ((var == &V_ipport_firstauto && port > V_ipport_lastauto) ||
+ (var == &V_ipport_lastauto && port < V_ipport_firstauto) ||
+ (var == &V_ipport_hifirstauto && port > V_ipport_hilastauto) ||
+ (var == &V_ipport_hilastauto && port < V_ipport_hifirstauto))
+ return (EINVAL);
+ *var = port;
+ return (0);
}
#undef RANGECHK
@@ -799,7 +807,7 @@
#endif
if (V_ipport_randomized) {
- port = first + (arc4random() % (last - first));
+ port = first + (arc4random() % (last - first + 1));
} else {
port = atomic_fetchadd_int(lastport, 1);
if (__predict_false(port < first || port > last)) {
@@ -808,7 +816,7 @@
}
}
- for (count = last - first; count > 0; count--) {
+ for (count = last - first + 1; count > 0; count--) {
struct inpcbinfo_ctx tmpctx = {
.pcbinfo = ipictx->pcbinfo
};

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 20, 11:22 PM (19 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41386030
Default Alt Text
D61010.1795216934.diff (1 KB)

Event Timeline