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.
This commit is contained in:
riastradh 2017-07-28 13:58:47 +00:00
parent e80123a9be
commit a62f05d75e
1 changed files with 7 additions and 6 deletions

View File

@ -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];