You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
contrib: makeseeds.py parseline() raises IndexError on lines with exactly 11 fields #36146
While reading through contrib/seeds/makeseeds.py I noticed parseline() can crash on a malformed line instead of skipping it.
The function checks that a line has enough columns:
iflen(sline) <11:
# line too short to be valid, skip it.returnNone
but further down it does:
agent=sline[11][1:-1]
sline[11] is the 12th column, so a valid line actually needs 12 fields, not 11. A line with exactly 11 fields gets past the check and then throws IndexError. 11 is the highest index the function uses, so the check should be < 12.
9 and 10 fields return None like they should, 12 fields parse fine, only 11 crashes.
It takes down the whole run, because main() calls it in a list comprehension with no try/except:
Loading asmap database "asmap.dat"...Done.
Loading and parsing DNS seeds...Traceback (most recent call last):
File "contrib/seeds/makeseeds.py", line 270, in <module>
main()
File "contrib/seeds/makeseeds.py", line 219, in main
ips = [parseline(line) for line in lines]
^^^^^^^^^^^^^^^
File "contrib/seeds/makeseeds.py", line 118, in parseline
agent = sline[11][1:-1]
~~~~~^^^^
IndexError: list index out of range
Annoying because it happens after the asmap database is already loaded, so that work is wasted too.
Expected: an 11 field line should return None and get skipped, same as 9 and 10.
This isn't only theoretical. README.md builds seeds_main.txt by appending one crawler's output onto another's:
so the file is a mix of two independently maintained formats, and a truncated download would leave a short last line as well. That's the case the check is there for.
There's no test covering makeseeds, so this isn't caught anywhere. Happy to open a PR with the fix and a test for it.
Activity
l0rinc commentedon Sep 2, 2026
Concept ACK, the off by one seems real. Even if not noticed for the past decade, might be worth fixing it.
amannx21 commentedon Sep 2, 2026
ok than i will work on it and open a PR.
fanquake commentedon Sep 14, 2026
Closing for now, as I don't think we need an issue open for this, given a PR exists: #36151.
Merge #36151: makeseeds: fix off-by-one in field count check