shadow1ng/fscan · error

parser_start_gt_end

Error message

parser_start_gt_end

What it means

parseIPFullRange converts both IPv4 endpoints to 32-bit integers and requires the start to be less than or equal to the end. When startInt > endInt the range would be empty/backwards, so this error is returned.

Source

Thrown at common/parsers/parsers.go:407

		allIP = append(allIP, fmt.Sprintf("%s.%d", prefixIP, i))
	}

	return allIP, nil
}

// parseIPFullRange 解析完整格式的IP范围
func parseIPFullRange(startIP, endIP net.IP) ([]string, error) {
	start4 := startIP.To4()
	end4 := endIP.To4()
	if start4 == nil || end4 == nil {
		return nil, fmt.Errorf("%s", i18n.GetText("parser_ipv4_only"))
	}

	startInt := (int(start4[0]) << 24) | (int(start4[1]) << 16) | (int(start4[2]) << 8) | int(start4[3])
	endInt := (int(end4[0]) << 24) | (int(end4[1]) << 16) | (int(end4[2]) << 8) | int(end4[3])

	if startInt > endInt {
		return nil, fmt.Errorf("%s", i18n.GetText("parser_start_gt_end"))
	}

	var ips []string
	current := make(net.IP, len(start4))
	copy(current, start4)

	for {
		ips = append(ips, current.String())
		if current.Equal(end4) {
			break
		}
		incrementIP(current)
	}

	return ips, nil
}

// incrementIP 计算下一个IP地址

View on GitHub (pinned to 95cc12e753)

Solutions

  1. Swap the endpoints so the start IP is <= the end IP, e.g. '192.168.1.10-192.168.1.254'.
  2. Pre-compare the parsed net.IP values in the caller and normalize the order before calling.
  3. Skip/emit a warning for empty ranges instead of passing backwards ones.

Example fix

// before
ParseIPRangeString("192.168.1.254-192.168.1.10")
// after
ParseIPRangeString("192.168.1.10-192.168.1.254")
Defensive patterns

Strategy: validation

Validate before calling

func orderedFullRange(startStr, endStr string) bool {
    s, e := net.ParseIP(startStr).To4(), net.ParseIP(endStr).To4()
    if s == nil || e == nil { return false }
    return bytes.Compare(s, e) <= 0
}

Try / catch

ips, err := parseIPRangeString(rangeStr)
if err != nil {
    return fmt.Errorf("range endpoints out of order in %q: %w", rangeStr, err)
}

Prevention

When it happens

Trigger: A full-format range like '192.168.1.254-192.168.1.10' where the start address numerically exceeds the end address.

Common situations: Swapped endpoints from copy-paste; ranges written descending intentionally (not supported); dynamically built ranges where the interval became empty after filtering.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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