Skip to contentSkip to conversation

apt: runtime error: filename too long (tmpdir length)

PATCH New [email protected] 2 participants 3 messages Jun 18, 2024 – Jul 16, 2024 2 messages not in the archive

lore
Share & tools
lore
#1 lore raw

PATCH v2 2/2 apt: runtime error: filename too long (tmpdir length)

In reply to a message not in the archive

From: Changqing Li <[email protected]>

when the tmpdir dir is longer than 220, there is no files saved in tmp/sysroots/x86_64-linux/var/lib/apt/lists/ after run apt-get update, this is because apt-get uses the path as the file name, but the file name can't be longer than 255 according to /usr/include/linux/limits.h.

[YOCTO #2688]

Take back from https://git.openembedded.org/openembedded-core/commit/?id=9a0c0393871eda4bbcecfdd4b595f0c1b8e42edf

---
 ...he-filename-can-t-be-longer-than-255.patch | 40 +++++++++++++++++++
 meta/recipes-devtools/apt/apt_2.6.1.bb        |  1 +
 2 files changed, 41 insertions(+)
 create mode 100644 meta/recipes-devtools/apt/apt/0001-strutl.cc-the-filename-can-t-be-longer-than-255.patch
meta/recipes-devtools/apt/apt/0001-strutl.cc-the-filename-can-t-be-longer-than-255.patch new file +40 -0
new file mode 100644
index 0000000000..c88efa3aae
@@ -0,0 +1,40 @@
+From 918295aa1320718d342116f76c98d2289d377800 Mon Sep 17 00:00:00 2001
+From: Changqing Li <[email protected]>
+Date: Tue, 18 Jun 2024 10:32:55 +0800
+Subject: [PATCH] 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: Submitted [https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1073591]
+Signed-off-by: Robert Yang <[email protected]>
+Signed-off-by: Changqing Li <[email protected]>
+---
+ 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
+index 67100f1..5076b35 100644
+--- a/apt-pkg/contrib/strutl.cc
++++ b/apt-pkg/contrib/strutl.cc
+@@ -565,7 +565,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		/*{{{*/
+-- 
+2.25.1
+
meta/recipes-devtools/apt/apt_2.6.1.bb +1 -0
index 26a6d99f84..b6b56c0010 100644
@@ -14,6 +14,7 @@ SRC_URI = "${DEBIAN_MIRROR}/main/a/apt/${BPN}_${PV}.tar.xz \
            file://0001-Hide-fstatat64-and-prlimit64-defines-on-musl.patch \
            file://0001-aptwebserver.cc-Include-array.patch \
            file://0001-Remove-using-std-binary_function.patch \
+           file://0001-strutl.cc-the-filename-can-t-be-longer-than-255.patch \
            "
 
 SRC_URI:append:class-native = " \
Signature · 1 line
2.25.1
#3 lore raw
In reply to a message not in the archive

ping

Quoted 86 lines · Changqing Li via lists.openembedded.org

From: Changqing Li<[email protected]>

when the tmpdir dir is longer than 220, there is no files saved in tmp/sysroots/x86_64-linux/var/lib/apt/lists/ after run apt-get update, this is because apt-get uses the path as the file name, but the file name can't be longer than 255 according to /usr/include/linux/limits.h.

[YOCTO #2688]

Take back fromhttps://git.openembedded.org/openembedded-core/commit/?id=9a0c0393871eda4bbcecfdd4b595f0c1b8e42edf

---
  ...he-filename-can-t-be-longer-than-255.patch | 40 +++++++++++++++++++
  meta/recipes-devtools/apt/apt_2.6.1.bb        |  1 +
  2 files changed, 41 insertions(+)

create mode 100644 meta/recipes-devtools/apt/apt/0001-strutl.cc-the-filename-can-t-be-longer-than-255.patch

meta/recipes-devtools/apt/apt/0001-strutl.cc-the-filename-can-t-be-longer-than-255.patch new file +40 -0
new file mode 100644
index 0000000000..c88efa3aae
@@ -0,0 +1,40 @@
+From 918295aa1320718d342116f76c98d2289d377800 Mon Sep 17 00:00:00 2001
+From: Changqing Li<[email protected]>
+Date: Tue, 18 Jun 2024 10:32:55 +0800
+Subject: [PATCH] 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: Submitted [https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1073591]
+Signed-off-by: Robert Yang<[email protected]>
+Signed-off-by: Changqing Li<[email protected]>
+---
+ 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
+index 67100f1..5076b35 100644
+--- a/apt-pkg/contrib/strutl.cc
++++ b/apt-pkg/contrib/strutl.cc
+@@ -565,7 +565,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		/*{{{*/
+--
+2.25.1
+
meta/recipes-devtools/apt/apt_2.6.1.bb +1 -1
index 26a6d99f84..b6b56c0010 100644
@@ -14,6 +14,7 @@ SRC_URI = "${DEBIAN_MIRROR}/main/a/apt/${BPN}_${PV}.tar.xz \
             file://0001-Hide-fstatat64-and-prlimit64-defines-on-musl.patch  \
             file://0001-aptwebserver.cc-Include-array.patch  \
             file://0001-Remove-using-std-binary_function.patch  \
+file://0001-strutl.cc-the-filename-can-t-be-longer-than-255.patch  \
             "
 
  SRC_URI:append:class-native = " \
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#200867):https://lists.openembedded.org/g/openembedded-core/message/200867 Mute This Topic:https://lists.openembedded.org/mt/106738366/3616873
Group Owner:[email protected] Unsubscribe:https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#4 lore raw

This proposed patch was rejected upstream:

Quoted 9 lines

Imagine as source:
deb http://example.org/very/very/long/path foo main
deb http://example.org/very/very/long/path bar main
that would roughly translate to e.g.:
example.org_very_very_long_path_dists_foo_main_binary-amd64_Packages example.org_very_very_long_path_dists_foo_main_binary-i386_Packages example.org_very_very_long_path_dists_bar_main_binary-amd64_Packages example.org_very_very_long_path_dists_bar_main_binary-i386_Packages

Quoted 3 lines

So, you can't just arbitrarily cut from the end as that potentially maps multiple URIs to the same filename (and while I am not sure if that method is UTF-8 safe, truncating is definitively not).

So I don’t think we should be accepting it, as this is exactly how it would be used.

Ross

Quoted 95 lines · Changqing Li via lists.openembedded.org

ping

Quoted 76 lines · Changqing Li via lists.openembedded.org

From: Changqing Li <[email protected]>

when the tmpdir dir is longer than 220, there is no files saved in tmp/sysroots/x86_64-linux/var/lib/apt/lists/ after run apt-get update, this is because apt-get uses the path as the file name, but the file name can't be longer than 255 according to /usr/include/linux/limits.h.

[YOCTO #2688]

Take back from https://git.openembedded.org/openembedded-core/commit/?id=9a0c0393871eda4bbcecfdd4b595f0c1b8e42edf

---
...he-filename-can-t-be-longer-than-255.patch | 40 +++++++++++++++++++ meta/recipes-devtools/apt/apt_2.6.1.bb | 1 +

2 files changed, 41 insertions(+)

create mode 100644 meta/recipes-devtools/apt/apt/0001-strutl.cc-the-filename-can-t-be-longer-than-255.patch

meta/recipes-devtools/apt/apt/0001-strutl.cc-the-filename-can-t-be-longer-than-255.patch new file +40 -0
new file mode 100644
index 0000000000..c88efa3aae
@@ -0,0 +1,40 @@
+From 918295aa1320718d342116f76c98d2289d377800 Mon Sep 17 00:00:00 2001
+From: Changqing Li <[email protected]>
+Date: Tue, 18 Jun 2024 10:32:55 +0800
+Subject: [PATCH] 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: Submitted [https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1073591]
+Signed-off-by: Robert Yang <[email protected]>
+Signed-off-by: Changqing Li <[email protected]>
+---
+ 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
+index 67100f1..5076b35 100644
+--- a/apt-pkg/contrib/strutl.cc
++++ b/apt-pkg/contrib/strutl.cc
+@@ -565,7 +565,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 /*{{{*/
+-- 
+2.25.1
+
meta/recipes-devtools/apt/apt_2.6.1.bb +1 -0
index 26a6d99f84..b6b56c0010 100644
@@ -14,6 +14,7 @@ SRC_URI = "${DEBIAN_MIRROR}/main/a/apt/${BPN}_${PV}.tar.xz \
 file://0001-Hide-fstatat64-and-prlimit64-defines-on-musl.patch \
 file://0001-aptwebserver.cc-Include-array.patch \
 file://0001-Remove-using-std-binary_function.patch \
+ file://0001-strutl.cc-the-filename-can-t-be-longer-than-255.patch \

"

Quoted 6 lines

SRC_URI:append:class-native = " \

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#201502): https://lists.openembedded.org/g/openembedded-core/message/201502
Mute This Topic: https://lists.openembedded.org/mt/106738366/6875888
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-