Author: loos
Date: Mon May 23 16:02:29 2016
New Revision: 300514
URL: https://svnweb.freebsd.org/changeset/base/300514

Log:
  MFC r297984:
  
  Make pfctl(8) more flexible when parsing bandwidth values.
  
  This is the current behaviour in OpenBSD and a similar patch exist in
  pfSense too.
  
  Obtained from:        OpenBSD (partly - rev. 1.625)
  Sponsored by: Rubicon Communications (Netgate)

Modified:
  stable/10/sbin/pfctl/parse.y
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sbin/pfctl/parse.y
==============================================================================
--- stable/10/sbin/pfctl/parse.y        Mon May 23 15:44:39 2016        
(r300513)
+++ stable/10/sbin/pfctl/parse.y        Mon May 23 16:02:29 2016        
(r300514)
@@ -1605,13 +1605,22 @@ bandwidth       : STRING {
 
                        bps = strtod($1, &cp);
                        if (cp != NULL) {
+                               if (strlen(cp) > 1) {
+                                       char *cu = cp + 1;
+                                       if (!strcmp(cu, "Bit") ||
+                                           !strcmp(cu, "B") ||
+                                           !strcmp(cu, "bit") ||
+                                           !strcmp(cu, "b")) {
+                                               *cu = 0;
+                                       }
+                               }
                                if (!strcmp(cp, "b"))
                                        ; /* nothing */
-                               else if (!strcmp(cp, "Kb"))
+                               else if (!strcmp(cp, "K"))
                                        bps *= 1000;
-                               else if (!strcmp(cp, "Mb"))
+                               else if (!strcmp(cp, "M"))
                                        bps *= 1000 * 1000;
-                               else if (!strcmp(cp, "Gb"))
+                               else if (!strcmp(cp, "G"))
                                        bps *= 1000 * 1000 * 1000;
                                else if (!strcmp(cp, "%")) {
                                        if (bps < 0 || bps > 100) {
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "[email protected]"

Reply via email to