shadow1ng/fscan · error

parser_invalid_ip_end_val

Error message

parser_invalid_ip_end_val

What it means

The short-tail end of a range (an octet number rather than a full IP, e.g. "10.0.0.1-50") must parse as an integer between 0 and 255. When strconv.Atoi fails or the number exceeds 255, newRangeHostSource returns this message naming the invalid end value.

Source

Thrown at common/parsers/host_iterator.go:360

}

func newRangeHostSource(rangeStr string) (hostSource, error) {
	parts := strings.Split(rangeStr, "-")
	if len(parts) != 2 {
		return nil, fmt.Errorf("%s", i18n.Tr("parser_invalid_ip_range_fmt", rangeStr))
	}

	startIPStr := strings.TrimSpace(parts[0])
	endIPStr := strings.TrimSpace(parts[1])
	startIP := net.ParseIP(startIPStr)
	if startIP == nil {
		return nil, fmt.Errorf("%s", i18n.Tr("parser_invalid_start_ip", startIPStr))
	}

	if len(endIPStr) < 4 || !strings.Contains(endIPStr, ".") {
		endNum, err := strconv.Atoi(endIPStr)
		if err != nil || endNum > 255 {
			return nil, fmt.Errorf("%s", i18n.Tr("parser_invalid_ip_end_val", endIPStr))
		}
		parts := strings.Split(startIPStr, ".")
		if len(parts) != 4 {
			return nil, fmt.Errorf("%s", i18n.Tr("parser_invalid_ip_fmt", startIPStr))
		}
		parts[3] = strconv.Itoa(endNum)
		endIPStr = strings.Join(parts, ".")
	}

	start, ok := ipToUint32(startIP)
	if !ok {
		return nil, fmt.Errorf("%s", i18n.GetText("parser_ipv4_only"))
	}
	end, ok := ipToUint32(net.ParseIP(endIPStr))
	if !ok {
		return nil, fmt.Errorf("%s", i18n.Tr("parser_invalid_end_ip", endIPStr))
	}
	if start > end {

View on GitHub (pinned to 95cc12e753)

Solutions

  1. Use an end octet in the range 0–255: "10.0.0.1-254".
  2. If the end host is above .255, specify a full end IP: "10.0.0.1-10.0.1.50".
  3. Pre-validate: if the tail is not dotted, check strconv.Atoi succeeds and value <= 255 before calling addRange.

Example fix

// before
m.AddRange("192.168.0.1-999") // parser_invalid_ip_end_val

// after
m.AddRange("192.168.0.1-192.168.1.100") // full end IP for cross-octet ranges
Defensive patterns

Strategy: validation

Validate before calling

func validEndTail(rng string) bool {
    parts := strings.SplitN(rng, "-", 2)
    if len(parts) != 2 {
        return false
    }
    tail := strings.TrimSpace(parts[1])
    if strings.Contains(tail, ".") {
        return net.ParseIP(tail) != nil
    }
    n, err := strconv.Atoi(tail)
    return err == nil && n >= 0 && n <= 255
}

Try / catch

if err := matcher.AddRange(rng); err != nil {
    log.Printf("bad range tail in %q: %v", rng, err)
    return nil
}

Prevention

When it happens

Trigger: addRange with "10.0.0.1-300", "10.0.0.1-abc", or "10.0.0.1-" where the tail is neither a full dotted IP nor a numeric octet in 0–255.

Common situations: Typing 256–999 as the last octet ("192.168.0.1-999"); accidentally using a port number as the tail ("10.0.0.1-8080"); non-numeric garbage from a malformed config line.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06). Data as JSON: /api/errors/80e0ff8a15ec6e95. Report an issue: GitHub.