From: Stuart Henderson Subject: Re: pfctl checking of bandwidth specs To: Alexandr Nedvedicky , Andy Lemin , tech@openbsd.org Date: Thu, 19 Mar 2026 15:29:58 +0000 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? 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]); }