Bug 263240

Summary: IPFW tools: Parsing error in nat config port_range
Product: Base System Reporter: Andrey Linkevich <dl>
Component: binAssignee: Lutz Donnerhacke <donner>
Status: New ---    
Severity: Affects Some People CC: aepot, donner
Priority: ---    
Version: Unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
IPFW NAT config: port range parsing fix none

Description Andrey Linkevich 2022-04-12 14:10:44 UTC
Created attachment 233165 [details]
IPFW NAT config: port range parsing fix

Hello, Colleagues.

In ipfw error with parsing "ipfw nat 11 config port_range 1025-65535". Forever "You need a range of port(s) from 1024 <= x < 65536".

Two errors in /usr/src/sbin/ipfw/nat.c nat_port_alias_parse().

Patch attached.

Thanks.
Comment 1 Lutz Donnerhacke freebsd_committer freebsd_triage 2022-04-13 06:44:38 UTC
Thank you for reporting this issue.

I wonder why the error occurs at all.
Somebody should tested this during development.
Comment 2 Yuri 2022-04-13 07:03:08 UTC
You don't need the checks for !ptr (which should have been written as ptr == NULL anyway), strtol() does not seem to set endptr to NULL ever.
Comment 3 Alexander 2022-11-06 14:40:12 UTC
Also after applying the patch nat_show_cfg() doesn't display port_range by cmd:

ipfw nat 1 show config

But looks like the patch works regardless of a room for improvement there