View | Details | Raw Unified | Return to bug 146125
Collapse All | Expand All

(-)libpar2/Makefile (-2 / +10 lines)
Lines 7-13 Link Here
7
7
8
PORTNAME=	libpar2
8
PORTNAME=	libpar2
9
PORTVERSION=	0.2
9
PORTVERSION=	0.2
10
PORTREVISION=	2
10
PORTREVISION=	3
11
CATEGORIES=	archivers
11
CATEGORIES=	archivers
12
MASTER_SITES=	SF/parchive/${PORTNAME}/${PORTVERSION}
12
MASTER_SITES=	SF/parchive/${PORTNAME}/${PORTVERSION}
13
DISTNAME=	${PORTNAME}-${PORTVERSION}
13
DISTNAME=	${PORTNAME}-${PORTVERSION}
Lines 24-33 Link Here
24
24
25
USE_LDCONFIG=	yes
25
USE_LDCONFIG=	yes
26
26
27
OPTIONS=	ENABLECANCEL "Enable graceful cancellation of repairs" On
28
29
.include <bsd.port.pre.mk>
30
31
.if defined(WITH_ENABLECANCEL)
32
EXTRA_PATCHES+=	${FILESDIR}/xpatch-addcancel-par2repairer.cpp
33
.endif
34
27
post-install:
35
post-install:
28
.if !defined(NOPORTDOCS)
36
.if !defined(NOPORTDOCS)
29
	@${MKDIR} ${DOCSDIR}
37
	@${MKDIR} ${DOCSDIR}
30
	${INSTALL_MAN} ${WRKSRC}/README ${DOCSDIR}
38
	${INSTALL_MAN} ${WRKSRC}/README ${DOCSDIR}
31
.endif
39
.endif
32
40
33
.include <bsd.port.mk>
41
.include <bsd.port.post.mk>
(-)libpar2/files/patch-ChangeLog (-3 / +7 lines)
Lines 1-6 Link Here
1
--- ChangeLog.orig	2006-02-03 08:07:23.000000000 -0800
1
--- ChangeLog.orig	2010-04-28 12:17:05.000000000 -0700
2
+++ ChangeLog	2008-08-16 13:10:41.000000000 -0700
2
+++ ChangeLog	2010-04-28 12:16:35.000000000 -0700
3
@@ -1,3 +1,6 @@
3
@@ -1,3 +1,10 @@
4
+28 Apr 2010 FreeBSD Port
5
+	* Fix memory leak/segfault under certain circumstances.
6
+           http://sf.net/tracker/?func=detail&aid=2209433&group_id=30568&atid=399700
7
+
4
+16 Aug 2008 FreeBSD Port
8
+16 Aug 2008 FreeBSD Port
5
+	* Fix 2G overflow for data_size (backported from vendor CVS)
9
+	* Fix 2G overflow for data_size (backported from vendor CVS)
6
+
10
+
(-)libpar2/files/patch-par2repairer.cpp (+36 lines)
Line 0 Link Here
1
#####
2
# This patch is maintained by Andrei Prygounkov, author of news/nzbget
3
# It fixes a memory leak and a segfault triggered by a corrupted par2 file.
4
#
5
# For more details, see:
6
#       http://sf.net/tracker/?func=detail&aid=2209433&group_id=30568&atid=399700
7
#####
8
diff -aud ../libpar2-0.2-original/par2repairer.cpp ../libpar2-0.2/par2repairer.cpp
9
--- ../libpar2-0.2-original/par2repairer.cpp	2006-01-20 18:25:20.000000000 +0100
10
+++ ../libpar2-0.2/par2repairer.cpp	2008-02-06 12:02:53.226050300 +0100
11
@@ -78,6 +78,7 @@
12
 
13
   delete mainpacket;
14
   delete creatorpacket;
15
+  delete headers;
16
 }
17
 
18
 
19
@@ -1261,7 +1262,7 @@
20
         DiskFile::SplitFilename(filename, path, name);
21
 
22
         cout << "Target: \"" << name << "\" - missing." << endl;
23
-	sig_done.emit(name, 0, sourcefile->GetVerificationPacket()->BlockCount());
24
+	sig_done.emit(name, 0, sourcefile->GetVerificationPacket() ? sourcefile->GetVerificationPacket()->BlockCount() : 0);
25
       }
26
     }
27
 
28
@@ -1804,7 +1805,7 @@
29
       }
30
     }
31
   }
32
-  sig_done.emit(name,count,sourcefile->GetVerificationPacket()->BlockCount()); 
33
+  sig_done.emit(name,count, sourcefile->GetVerificationPacket() ? sourcefile->GetVerificationPacket()->BlockCount() : 0); 
34
   sig_progress.emit(1000.0);
35
   return true;
36
 }
(-)libpar2/files/xpatch-addcancel-par2repairer.cpp (+194 lines)
Line 0 Link Here
1
#####
2
# This patch is maintained by Andrei Prygounkov, author of news/nzbget
3
# It adds a graceful method to cancel file repair operations in progress.
4
#
5
# For more details, see: 
6
#	http://sf.net/tracker/?func=detail&aid=2209488&group_id=30568&atid=399700 
7
#####
8
diff -aud ../libpar2-0.2-original/par2repairer.cpp ../libpar2-0.2/par2repairer.cpp
9
--- ../libpar2-0.2-original/par2repairer.cpp	2008-10-26 19:54:33.000000000 +0100
10
+++ ../libpar2-0.2/par2repairer.cpp	2008-10-29 10:24:48.000000000 +0100
11
@@ -52,6 +52,8 @@
12
   noiselevel = CommandLine::nlNormal;
13
   headers = new ParHeaders;
14
   alreadyloaded = false;
15
+
16
+  cancelled = false;
17
 }
18
 
19
 Par2Repairer::~Par2Repairer(void)
20
@@ -406,6 +408,10 @@
21
           progress = offset;
22
 	sig_progress.emit(newfraction);
23
 
24
+          if (cancelled)
25
+          {
26
+            break;
27
+          }
28
         }
29
       }
30
 
31
@@ -584,6 +590,11 @@
32
     delete diskfile;
33
   }
34
   
35
+  if (cancelled)
36
+  {
37
+    return false;
38
+  }
39
+
40
   return true;
41
 }
42
 
43
@@ -833,9 +844,17 @@
44
     for (list<string>::const_iterator s=files->begin(); s!=files->end(); ++s)
45
     {
46
       LoadPacketsFromFile(*s);
47
+      if (cancelled)
48
+      {
49
+        break;
50
+      }
51
     }
52
 
53
     delete files;
54
+    if (cancelled)
55
+    {
56
+      return false;
57
+    }
58
   }
59
 
60
   {
61
@@ -846,9 +865,17 @@
62
     for (list<string>::const_iterator s=files->begin(); s!=files->end(); ++s)
63
     {
64
       LoadPacketsFromFile(*s);
65
+      if (cancelled)
66
+      {
67
+        break;
68
+      }
69
     }
70
 
71
     delete files;
72
+    if (cancelled)
73
+    {
74
+      return false;
75
+    }
76
   }
77
 
78
   return true;
79
@@ -866,9 +893,18 @@
80
         string::npos != filename.find(".PAR2"))
81
     {
82
       LoadPacketsFromFile(filename);
83
+      if (cancelled)
84
+      {
85
+        break;
86
+      }
87
     }
88
   }
89
 
90
+  if (cancelled)
91
+  {
92
+    return false;
93
+  }
94
+
95
   return true;
96
 }
97
 
98
@@ -1210,6 +1246,11 @@
99
   sf = sortedfiles.begin();
100
   while (sf != sortedfiles.end())
101
   {
102
+    if (cancelled)
103
+    {
104
+      return false;
105
+    }
106
+
107
     // Do we have a source file
108
     Par2RepairerSourceFile *sourcefile = *sf;
109
 
110
@@ -1562,6 +1603,10 @@
111
         cout << "Scanning: \"" << shortname << "\": " << newfraction/10 << '.' << newfraction%10 << "%\r" << flush;
112
 	sig_progress.emit(newfraction);
113
 
114
+        if (cancelled)
115
+        {
116
+          break;
117
+        }
118
       }
119
     }
120
 
121
@@ -1651,6 +1696,11 @@
122
     }
123
   }
124
 
125
+  if (cancelled)
126
+  {
127
+    return false;
128
+  }
129
+
130
   // Get the Full and 16k hash values of the file
131
   filechecksummer.GetFileHashes(hashfull, hash16k);
132
 
133
@@ -2291,10 +2341,19 @@
134
             cout << "Repairing: " << newfraction/10 << '.' << newfraction%10 << "%\r" << flush;
135
 	    sig_progress.emit(newfraction);
136
 
137
+            if (cancelled)
138
+            {
139
+              break;
140
+            }
141
           }
142
         }
143
       }
144
 
145
+      if (cancelled)
146
+      {
147
+        break;
148
+      }
149
+
150
       ++inputblock;
151
       ++inputindex;
152
     }
153
@@ -2348,9 +2407,18 @@
154
           cout << "Processing: " << newfraction/10 << '.' << newfraction%10 << "%\r" << flush;
155
 	sig_progress.emit(newfraction);
156
 
157
+          if (cancelled)
158
+          {
159
+            break;
160
+          }
161
         }
162
       }
163
 
164
+      if (cancelled)
165
+      {
166
+        break;
167
+      }
168
+
169
       ++copyblock;
170
       ++inputblock;
171
     }
172
@@ -2362,6 +2430,11 @@
173
     lastopenfile->Close();
174
   }
175
 
176
+  if (cancelled)
177
+  {
178
+    return false;
179
+  }
180
+
181
   if (noiselevel > CommandLine::nlQuiet)
182
     cout << "Writing recovered data\r";
183
 
184
diff -aud ../libpar2-0.2-original/par2repairer.h ../libpar2-0.2/par2repairer.h
185
--- ../libpar2-0.2-original/par2repairer.h	2006-01-20 00:38:27.000000000 +0100
186
+++ ../libpar2-0.2/par2repairer.h	2008-10-26 19:01:08.000000000 +0100
187
@@ -183,6 +183,7 @@
188
   u64                       totaldata;               // Total amount of data to be processed.
189
   u64                       totalsize;               // Total data size
190
 
191
+  bool                      cancelled;               // repair cancelled
192
 };
193
 
194
 #endif // __PAR2REPAIRER_H__

Return to bug 146125