shadow1ng/fscan · error
parser_invalid_ip_end_val
Error message
parser_invalid_ip_end_val
What it means
parseIPShortRange parses shorthand IP ranges like '192.168.1.10-50'. The end suffix (the number after '-') must parse as an integer and be <= 255; otherwise this error is returned with the offending suffix in the message. The library throws it to reject malformed or out-of-octet range endings before building the IP list.
Source
Thrown at common/parsers/parsers.go:373
// 处理简写格式 (如: 192.168.1.1-100)
if len(endIPStr) < 4 || !strings.Contains(endIPStr, ".") {
return parseIPShortRange(startIPStr, endIPStr)
}
// 处理完整格式 (如: 192.168.1.1-192.168.1.100)
endIP := net.ParseIP(endIPStr)
if endIP == nil {
return nil, fmt.Errorf("%s", i18n.Tr("parser_invalid_end_ip", endIPStr))
}
return parseIPFullRange(startIP, endIP)
}
// parseIPShortRange 解析短格式IP范围
func parseIPShortRange(startIPStr, endSuffix string) ([]string, error) {
endNum, err := strconv.Atoi(endSuffix)
if err != nil || endNum > 255 {
return nil, fmt.Errorf("%s", i18n.Tr("parser_invalid_ip_end_val", endSuffix))
}
ipParts := strings.Split(startIPStr, ".")
if len(ipParts) != 4 {
return nil, fmt.Errorf("%s", i18n.Tr("parser_invalid_ip_fmt", startIPStr))
}
prefixIP := strings.Join(ipParts[0:3], ".")
startNum, err := strconv.Atoi(ipParts[3])
if err != nil || startNum > endNum {
return nil, fmt.Errorf("%s", i18n.Tr("parser_invalid_ip_range_val", startIPStr, endSuffix))
}
var allIP []string
for i := startNum; i <= endNum; i++ {
allIP = append(allIP, fmt.Sprintf("%s.%d", prefixIP, i))
}
View on GitHub (pinned to 95cc12e753)
Solutions
- Correct the range string so the end suffix is an integer between 0 and 255 (e.g. '192.168.1.10-50').
- If the range end needs to span octets (e.g. .200 to .1.10), use the full format 'startIP-endIP' instead of the short form.
- Trim whitespace/stray characters from the range input before parsing.
Example fix
// before
ParseIPRangeString("192.168.1.10-300")
// after
ParseIPRangeString("192.168.1.10-255") // or full format "192.168.1.10-192.168.2.30" Defensive patterns
Strategy: validation
Validate before calling
func validShortRange(r string) bool {
i := strings.IndexByte(r, '-')
if i < 0 { return false }
end, err := strconv.Atoi(r[i+1:])
return err == nil && end >= 0 && end <= 255
} Try / catch
ips, err := parseIPRangeString(rangeStr)
if err != nil {
return fmt.Errorf("invalid short IP range %q: %w", rangeStr, err)
} Prevention
- Validate the end octet is an integer 0-255 before passing short-form ranges
- Use the full start-end format when the range spans more than one octet
- Trim and sanitize user-supplied range strings
When it happens
Trigger: Calling parseIPRangeString with a short-form range whose end suffix is non-numeric (e.g. '192.168.1.10-abc') or greater than 255 (e.g. '192.168.1.10-300').
Common situations: Hand-edited config files or CLI args where the end octet was mistyped, copy-pasted values containing stray characters, or assuming the end may exceed one octet as in a full range format.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- parser_ip_range_failed: %w
- parser_invalid_ip_range_val
- parser_cidr_failed: %w
- parser_start_gt_end
- parser_invalid_ip_fmt
AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06).
Data as JSON: /api/errors/2220195ce8ab0949.
Report an issue: GitHub.