From owner-svn-src-stable@freebsd.org Mon May 23 16:02:30 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8EACB47C99; Mon, 23 May 2016 16:02:30 +0000 (UTC) (envelope-from loos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9808D1281; Mon, 23 May 2016 16:02:30 +0000 (UTC) (envelope-from loos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4NG2TJH084754; Mon, 23 May 2016 16:02:29 GMT (envelope-from loos@FreeBSD.org) Received: (from loos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4NG2TuD084753; Mon, 23 May 2016 16:02:29 GMT (envelope-from loos@FreeBSD.org) Message-Id: <201605231602.u4NG2TuD084753@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: loos set sender to loos@FreeBSD.org using -f From: Luiz Otavio O Souza Date: Mon, 23 May 2016 16:02:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r300514 - stable/10/sbin/pfctl X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 May 2016 16:02:30 -0000 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) {