Module Name: src
Committed By: riastradh
Date: Fri Jul 28 13:58:47 UTC 2017
Modified Files:
src/sys/altq: altq_wfq.c
Log Message:
Reject negative indices.
(Would be nice to change the types too, and it's *probably* safe to
replace int by u_int, but I'm reluctant to touch the ioctl
definitions without at least a modicum more thought. Also one of
them is a u_long, because why not?)
>From Ilja Van Sprundel.
To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/altq/altq_wfq.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/altq/altq_wfq.c
diff -u src/sys/altq/altq_wfq.c:1.21 src/sys/altq/altq_wfq.c:1.22
--- src/sys/altq/altq_wfq.c:1.21 Wed Apr 20 08:58:48 2016
+++ src/sys/altq/altq_wfq.c Fri Jul 28 13:58:47 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: altq_wfq.c,v 1.21 2016/04/20 08:58:48 knakahara Exp $ */
+/* $NetBSD: altq_wfq.c,v 1.22 2017/07/28 13:58:47 riastradh Exp $ */
/* $KAME: altq_wfq.c,v 1.14 2005/04/13 03:44:25 suz Exp $ */
/*
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: altq_wfq.c,v 1.21 2016/04/20 08:58:48 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_wfq.c,v 1.22 2017/07/28 13:58:47 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_altq.h"
@@ -517,14 +517,15 @@ wfq_setweight(struct wfq_setweight *swp)
wfq *queue;
int old;
- if (swp->weight < 0) {
- printf("set weight in natural number\n");
+ if (swp->weight < 0)
return (EINVAL);
- }
if ((wfqp = altq_lookup(swp->iface.wfq_ifacename, ALTQT_WFQ)) == NULL)
return (EBADF);
+ if (swp->qid < 0 || swp->qid >= wfqp->nums)
+ return (EINVAL);
+
queue = &wfqp->queue[swp->qid];
old = queue->weight;
queue->weight = swp->weight;
@@ -543,7 +544,7 @@ wfq_getstats(struct wfq_getstats *gsp)
if ((wfqp = altq_lookup(gsp->iface.wfq_ifacename, ALTQT_WFQ)) == NULL)
return (EBADF);
- if (gsp->qid >= wfqp->nums)
+ if (gsp->qid < 0 || gsp->qid >= wfqp->nums)
return (EINVAL);
queue = &wfqp->queue[gsp->qid];