From 4f655e4f6914335f297f6d8e09ea6a6e48644a21 Mon Sep 17 00:00:00 2001 From: Henning Brauer Date: Sat, 8 Mar 2003 14:52:18 +0000 Subject: in expand_queue, make a private copy of the struct pf_altq before modifying it. modifying the original one had undesired side effects if a queue was expanded to more than one because it belonged to more than one interface ok pb@ cedric@ dhartmei@ --- sbin/pfctl/parse.y | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'sbin') diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index c088b246fb3..736adb5a542 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.336 2003/03/06 12:50:40 henning Exp $ */ +/* $OpenBSD: parse.y,v 1.337 2003/03/08 14:52:17 henning Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. @@ -3136,6 +3136,7 @@ expand_queue(struct pf_altq *a, struct node_queue *nqueues, struct node_queue_bw bwspec) { struct node_queue *n; + struct pf_altq pa; u_int8_t added = 0; u_int8_t found = 0; @@ -3149,16 +3150,18 @@ expand_queue(struct pf_altq *a, struct node_queue *nqueues, /* found ourselve in queues */ found++; - if (a->scheduler != ALTQT_NONE && - a->scheduler != tqueue->scheduler) { + memcpy(&pa, a, sizeof(struct pf_altq)); + + if (pa.scheduler != ALTQT_NONE && + pa.scheduler != tqueue->scheduler) { yyerror("exactly one scheduler type per " "interface allowed"); return (1); } - a->scheduler = tqueue->scheduler; + pa.scheduler = tqueue->scheduler; /* scheduler dependent error checking */ - switch (a->scheduler) { + switch (pa.scheduler) { case ALTQT_PRIQ: if (nqueues != NULL) { yyerror("priq queues cannot have " @@ -3198,16 +3201,16 @@ expand_queue(struct pf_altq *a, struct node_queue *nqueues, queues->tail = n; } ); - if (strlcpy(a->ifname, tqueue->ifname, - sizeof(a->ifname)) >= sizeof(a->ifname)) + if (strlcpy(pa.ifname, tqueue->ifname, + sizeof(pa.ifname)) >= sizeof(pa.ifname)) errx(1, "expand_queue: strlcpy"); - if (strlcpy(a->parent, tqueue->parent, - sizeof(a->parent)) >= sizeof(a->parent)) + if (strlcpy(pa.parent, tqueue->parent, + sizeof(pa.parent)) >= sizeof(pa.parent)) errx(1, "expand_queue: strlcpy"); - if (!eval_pfqueue(pf, a, bwspec.bw_absolute, + if (!eval_pfqueue(pf, &pa, bwspec.bw_absolute, bwspec.bw_percent)) - if (!pfctl_add_altq(pf, a)) + if (!pfctl_add_altq(pf, &pa)) added++; } ); -- cgit v1.2.3