summaryrefslogtreecommitdiff
path: root/net-p2p/ctorrent/files/ctorrent-3.3.2-empty-path-components.patch
blob: fce41d4feff5a861b825258a24ef683dd6b8de00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
rTorrent sometimes creates invalid torrents which has empty path components.
the bitorrent spec allows for "" strings, but they make no sense in paths.
so instead of always adding a / in between, skip them.  ugh.

for example:
dict {
	'info' => dict {
		'name' => str = "some dir" (len = 8)
		'files' => list [
			dict {
				'length' => int = 12345567
				'path' => list [
					str = "" (len = 0)
					str = "foo.bin" (len = 7)
				]
			}
			...
		]
		...
	}
	...
}

ctorrent will then try to fetch the file "/some dir/foo.bin" instead of
"some dir/foo.bin" (relative to $PWD).

--- a/bencode.cpp
+++ b/bencode.cpp
@@ -258,7 +258,8 @@
     n -= r; 
     if( 'e' == *pb ) break;
     if( pathname >= endmax ) return 0;
-    *pathname++ = PATH_SP;
+    if (q)
+      *pathname++ = PATH_SP;
   }
   *pathname = '\0';
   return (pb - b + 1);