blob: db1c42b66cf7de4a88976463685ec0b8070dfd8f [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001strutl.cc: the filename can't be longer than 255
2
3The URItoFileName translates the path into the filename, but the
4filename can't be longer than 255 according to
5/usr/include/linux/limits.h.
6
7Truncate it when it is longer than 240 (leave some spaces for
8".Packages" and "._Release" suffix)
9
10Upstream-Status: Pending
11Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
12---
13 apt-pkg/contrib/strutl.cc | 7 ++++++-
14 1 file changed, 6 insertions(+), 1 deletion(-)
15
16diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
17--- a/apt-pkg/contrib/strutl.cc
18+++ b/apt-pkg/contrib/strutl.cc
19@@ -399,7 +399,12 @@ string URItoFileName(const string &URI)
20 // "\x00-\x20{}|\\\\^\\[\\]<>\"\x7F-\xFF";
21 string NewURI = QuoteString(U,"\\|{}[]<>\"^~_=!@#$%^&*");
22 replace(NewURI.begin(),NewURI.end(),'/','_');
23- return NewURI;
24+
25+ // Truncate from the head when it is longer than 240
26+ if(NewURI.length() > 240)
27+ return NewURI.substr(NewURI.length() - 240, NewURI.length() - 1);
28+ else
29+ return NewURI;
30 }
31 /*}}}*/
32 // Base64Encode - Base64 Encoding routine for short strings /*{{{*/
33--
341.7.10.4
35