# Buggy code
def fetch():
    retval = {}
    content = retrieve_content(__url__)

    if __check__ in content:
        for match in re.finditer(r"([\d.]+)/(\d+)", content):
            prefix, mask = match.groups()
            start_int = addr_to_int(prefix) & make_mask(int(mask))
            end_int = start_int | ((1 << 32 - int(mask)) - 1)
            for address in xrange(start_int, end_int + 1):
                retval[int_to_addr(address)] = (__info__, __reference__)

    return retval


# Traceback (OverflowError)
[i] updating trails...
[o] 'https://feodotracker.abuse.ch/blocklist/?download=domainblocklist'
[!] something went wrong during remote data retrieval ('https://feodotracker.abuse.ch/blocklist/?download=domainblocklist')
[o] 'https://www.badips.com/get/list/any/2?age=30d'
[o] 'https://raw.githubusercontent.com/firehol/blocklist-ipsets/master/ri_web_proxies_30d.ipset'
[o] 'https://raw.githubusercontent.com/firehol/blocklist-ipsets/master/proxylists_30d.ipset'
[o] 'http://www.botscout.com/last_caught_cache.htm'
[o] 'http://vxvault.siri-urz.net/URL_List.php'
[o] 'http://malwaredomains.lehigh.edu/files/domains.txt'
[o] 'https://raw.githubusercontent.com/firehol/blocklist-ipsets/master/socks_proxy_30d.ipset'
[o] 'https://zeustracker.abuse.ch/blocklist.php?download=badips'
[o] 'https://openphish.com/feed.txt'
[o] 'https://myip.ms/files/blacklist/htaccess/latest_blacklist.txt'
[o] 'https://www.maxmind.com/en/proxy-detection-sample-list'
[o] 'https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist'
[o] 'http://malwareurls.joxeankoret.com/normal.txt'
[o] 'http://talosintel.com/feeds/ip-filter.blf'
[o] 'https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=1.1.1.1'
[o] 'https://rules.emergingthreats.net/open/suricata/rules/emerging-dns.rules'
[o] 'http://www.nothink.org/blacklist/blacklist_malware_irc.txt'
[o] 'http://danger.rulez.sk/projects/bruteforceblocker/blist.php'
[o] 'http://malwared.malwaremustdie.org/rss.php'
[o] 'http://www.voipbl.org/update/'
[!] Unhandled exception occurred ('Python int too large to convert to C long')
[x] Please report the following details at 'https://github.com/stamparm/maltrail/issues':

---
'Traceback (most recent call last):
File "sensor.py", line 389, in <module>
main()
File "sensor.py", line 382, in main
init()
File "sensor.py", line 287, in init
update_timer()
File "sensor.py", line 275, in update_timer
_ = update(server=config.UPDATE_SERVER)
File "/opt/maltrail/maltrail/core/update.py", line 82, in update
results = function()
File "/opt/maltrail/maltrail/trails/feeds/voipbl.py", line 29, in fetch
for address in xrange(start_int, end_int + 1):
OverflowError: Python int too large to convert to C long
'

---

# Fixed code
def fetch():
    retval = {}
    content = retrieve_content(__url__)

    if __check__ in content:
        for match in re.finditer(r"(\d+\.\d+\.\d+\.\d+)/(\d+)", content):
            prefix, mask = match.groups()
            mask = int(mask)
            if MIN_BLACKLIST_MASK <= mask <= MAX_BLACKLIST_MASK:
                start_int = addr_to_int(prefix) & make_mask(mask)
                end_int = start_int | ((1 << 32 - mask) - 1)
                for address in xrange(start_int, end_int + 1):
                    retval[int_to_addr(address)] = (__info__, __reference__)

    return retval