File pan-fix-empty-nzb-crash.patch of Package pan
From 29aad7ec8b2b0c74592342fcfa2aa3c830f9e592 Mon Sep 17 00:00:00 2001
From: "paul@flinders.org" <paul@flinders.org>
Date: Thu, 8 Feb 2018 21:28:07 +0100
Subject: Bug 793228 nzb file with empty segment lists crash pan
NZB files which have empty segment lists crash pan (up to 0.144),
for me typically at the assertion on the last line of
Parts :: set_parts (around parts.cc line 237).
The problem is that "mc.parts" is not re-initialised for the new
list of segments if the first segment is not seen, depending on
the position in the file you will either get an incompletely
constructed PartBatch used (PartBatch relies on a default
constructor so packed_mids_len doesn't get initialised) or an
old list of segments could get re-used.
---
pan/tasks/nzb.cc | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/pan/tasks/nzb.cc b/pan/tasks/nzb.cc
index e3e8547..af890e5 100644
--- a/pan/tasks/nzb.cc
+++ b/pan/tasks/nzb.cc
@@ -113,6 +113,8 @@ namespace
gpointer user_data,
GError **error UNUSED)
{
+ static Quark null_mid;
+
MyContext& mc (*static_cast<MyContext*>(user_data));
if (!strcmp (element_name, "file")) {
@@ -123,7 +125,9 @@ namespace
else if (!strcmp (*k,"date")) mc.a.time_posted = strtoul(*v,0,10);
}
}
-
+ else if (!strcmp (element_name, "segments")) {
+ mc.parts.init (null_mid);
+ }
else if (!strcmp (element_name, "segment")) {
mc.bytes = 0;
mc.number = 0;
--
cgit v0.12