From: Alexandr Nedvedicky Subject: Re: pfctl checking of bandwidth specs To: Andy Lemin , tech@openbsd.org Date: Fri, 20 Mar 2026 08:35:55 +0100 Hello, On Thu, Mar 19, 2026 at 03:29:58PM +0000, Stuart Henderson wrote: > On 2026/03/19 14:52, Crystal Kolipe wrote: > > The issue is with the printing code in pfctl_parser.c. > > ha, right. > > > Have a look at print_bwspec(), there is a hard coded array of unit specifiers, > > " KMG", and the 'i' loop is hard-coded to loop to 3. > > > > Adding "T" and changing the loop condition makes it work for me. > > the parser doesn't accept T on input (and it doesn't seem worth adding > that at present), so instead let's fix the 'for' condition to avoid > pointing at the trailing nul. > > ok? makes sense and looks good to me. thanks and OK sashan > > Index: pfctl_parser.c > =================================================================== > RCS file: /cvs/src/sbin/pfctl/pfctl_parser.c,v > diff -u -p -r1.358 pfctl_parser.c > --- pfctl_parser.c 19 Feb 2026 16:59:15 -0000 1.358 > +++ pfctl_parser.c 19 Mar 2026 15:26:40 -0000 > @@ -1279,7 +1279,7 @@ print_bwspec(const char *prefix, struct > printf("%s%u%%", prefix, bw->percent); > else if (bw->absolute) { > rate = bw->absolute; > - for (i = 0; rate >= 1000 && i <= 3 && (rate % 1000 == 0); i++) > + for (i = 0; rate >= 1000 && i < 3 && (rate % 1000 == 0); i++) > rate /= 1000; > printf("%s%llu%c", prefix, rate, unit[i]); > }