summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/apt/apt-0.9.8.2/truncate-filename.patch
blob: db1c42b66cf7de4a88976463685ec0b8070dfd8f (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
strutl.cc: the filename can't be longer than 255

The URItoFileName translates the path into the filename, but the
filename can't be longer than 255 according to
/usr/include/linux/limits.h.

Truncate it when it is longer than 240 (leave some spaces for
".Packages" and "._Release" suffix)

Upstream-Status: Pending
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 apt-pkg/contrib/strutl.cc |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -399,7 +399,12 @@ string URItoFileName(const string &URI)
    // "\x00-\x20{}|\\\\^\\[\\]<>\"\x7F-\xFF";
    string NewURI = QuoteString(U,"\\|{}[]<>\"^~_=!@#$%^&*");
    replace(NewURI.begin(),NewURI.end(),'/','_');
-   return NewURI;
+
+   // Truncate from the head when it is longer than 240
+   if(NewURI.length() > 240)
+       return NewURI.substr(NewURI.length() - 240, NewURI.length() - 1);
+   else
+       return NewURI;
 }
 									/*}}}*/
 // Base64Encode - Base64 Encoding routine for short strings		/*{{{*/
-- 
1.7.10.4