Closed sanderjo closed 5 years ago
Ugly code:
def decode(self, article, data, raw_data):
# Do we have SABYenc? Let it do all the work
if sabnzbd.decoder.SABYENC_ENABLED:
mytotal = 0
for myi in raw_data:
mytotal += len(myi)
logging.debug("SJ: length of raw_data (calculated): %d", mytotal )
logging.debug("SJ: article.bytes: %s", article.bytes)
#logging.debug("SJ: raw_data: %s", raw_data )
decoded_data, output_filename, crc, crc_expected, crc_correct = sabyenc.decode_usenet_chunks(raw_data, abs(article.bytes))
gives
019-06-21 08:07:00,846::INFO::[nzbstuff:1693] Checking all filenames for test-negative-segment-bytes-reftestnzb
2019-06-21 08:07:00,847::INFO::[nzbstuff:1696] Re-sorting test-negative-segment-bytes-reftestnzb after getting filename information
2019-06-21 08:07:03,647::DEBUG::[decoder:225] SJ: length of raw_data (calculated): 728203
2019-06-21 08:07:03,648::DEBUG::[decoder:226] SJ: article.bytes: -728845
2019-06-21 08:07:03,991::DEBUG::[decoder:225] SJ: length of raw_data (calculated): 728204
2019-06-21 08:07:03,992::DEBUG::[decoder:226] SJ: article.bytes: -728846
2019-06-21 08:07:04,681::DEBUG::[decoder:225] SJ: length of raw_data (calculated): 728207
2019-06-21 08:07:04,683::DEBUG::[decoder:226] SJ: article.bytes: -728906
2019-06-21 08:07:05,356::DEBUG::[decoder:225] SJ: length of raw_data (calculated): 728207
2019-06-21 08:07:05,357::DEBUG::[decoder:226] SJ: article.bytes: -728850
2019-06-21 08:07:05,630::DEBUG::[bpsmeter:268] bps: 1551934.70799
2019-06-21 08:07:05,733::DEBUG::[decoder:225] SJ: length of raw_data (calculated): 728207
2019-06-21 08:07:05,734::DEBUG::[decoder:226] SJ: article.bytes: -728850
... and the download works
Solved by https://github.com/sabnzbd/sabyenc/pull/15
Closing
As reported here https://forums.sabnzbd.org/viewtopic.php?f=3&t=24140&p=119081#p119081
Out of Memory with a NZB with all "segment bytes" parts set to negative value, for example 'segment bytes="-728914"'
Crafted NZB here https://raw.githubusercontent.com/sanderjo/NZBs/master/test-negative-segment-bytes-reftestnzb.nzb
Strange, because sabyenc seems to check for negative values before doing the mallo() https://github.com/sabnzbd/sabyenc/blob/sabyenc-python2/src/sabyenc.c#L563-L573
Doing malloc() with a negative number is very bad.