Skip to contentSkip to conversation

icu: increase command buffer size

PATCH Superseded Joe Slater 2 participants 2 messages Aug 5, 2021 – Aug 6, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Joe Slater

author
#0 lore raw

PATCH 1/1 icu: increase command buffer size

Make cmd in pkg_installLibrary() LARGE_BUFFER_SIZE to avoid pathname truncation if the install path is longer than about 150 characters. For default compilation, the U_ASSERT does not detect buffer overflow.

---
 ...pkgdata-increase-command-buffer-size.patch | 41 +++++++++++++++++++
 meta/recipes-support/icu/icu_69.1.bb          |  1 +
 2 files changed, 42 insertions(+)
 create mode 100644 meta/recipes-support/icu/icu/0001-pkgdata-increase-command-buffer-size.patch
meta/recipes-support/icu/icu/0001-pkgdata-increase-command-buffer-size.patch new file +41 -0
new file mode 100644
index 0000000000..14d17f9742
@@ -0,0 +1,41 @@
+From ab6b1acdeed76899f8227c38ab7e7675c7673ff1 Mon Sep 17 00:00:00 2001
+From: Joe Slater <[email protected]>
+Date: Thu, 5 Aug 2021 09:23:48 -0700
+Subject: [oe-core][PATCH 1/1] pkgdata: increase command buffer size
+
+Make cmd LARGE_BUFFER_SIZE to avoid pathname truncation
+when install paths are longer than about 150 characters.
+
+Signed-off-by: Joe Slater <[email protected]>
+---
+ source/tools/pkgdata/pkgdata.cpp | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/source/tools/pkgdata/pkgdata.cpp b/source/tools/pkgdata/pkgdata.cpp
+index 5ab682e..d4b70ef 100644
+--- a/tools/pkgdata/pkgdata.cpp
++++ b/tools/pkgdata/pkgdata.cpp
+@@ -1131,17 +1131,17 @@ normal_symlink_mode:
+ 
+ static int32_t pkg_installLibrary(const char *installDir, const char *targetDir, UBool noVersion) {
+     int32_t result = 0;
+-    char cmd[SMALL_BUFFER_MAX_SIZE];
++    char cmd[LARGE_BUFFER_MAX_SIZE];
+ 
+     auto ret = snprintf(cmd,
+-            SMALL_BUFFER_MAX_SIZE,
++            LARGE_BUFFER_MAX_SIZE,
+             "cd %s && %s %s %s%s%s",
+             targetDir,
+             pkgDataFlags[INSTALL_CMD],
+             libFileNames[LIB_FILE_VERSION],
+             installDir, PKGDATA_FILE_SEP_STRING, libFileNames[LIB_FILE_VERSION]);
+     (void)ret;
+-    U_ASSERT(0 <= ret && ret < SMALL_BUFFER_MAX_SIZE);
++    U_ASSERT(0 <= ret && ret < LARGE_BUFFER_MAX_SIZE);
+ 
+     result = runCommand(cmd);
+ 
+-- 
+2.29.2
+
meta/recipes-support/icu/icu_69.1.bb +1 -0
index bfeea8d2f0..00c22372b5 100644
@@ -107,6 +107,7 @@ SRC_URI = "${BASE_SRC_URI};name=code \
            file://filter.json \
            file://fix-install-manx.patch \
            file://0001-icu-Added-armeb-support.patch \
+           file://0001-pkgdata-increase-command-buffer-size.patch \
            "
 
 SRC_URI_append_class-target = "\
Signature · 1 line
2.29.2
#1 lore raw

Upstream-Status is missing, and this looks like something that should be sent upstream first for review.

Alex

Quoted 86 lines · Joe Slater

Make cmd in pkg_installLibrary() LARGE_BUFFER_SIZE to avoid pathname truncation if the install path is longer than about 150 characters. For default compilation, the U_ASSERT does not detect buffer overflow.

---
 ...pkgdata-increase-command-buffer-size.patch | 41 +++++++++++++++++++
 meta/recipes-support/icu/icu_69.1.bb          |  1 +
 2 files changed, 42 insertions(+)
 create mode 100644

meta/recipes-support/icu/icu/0001-pkgdata-increase-command-buffer-size.patch

diff --git a/meta/recipes-support/icu/icu/0001-pkgdata-increase-command-buffer-size.patch b/meta/recipes-support/icu/icu/0001-pkgdata-increase-command-buffer-size.patch new file mode 100644
index 0000000000..14d17f9742
--- /dev/null
+++
b/meta/recipes-support/icu/icu/0001-pkgdata-increase-command-buffer-size.patch

meta/recipes-support/icu/icu/0001-pkgdata-increase-command-buffer-size.patch new file +14 -0
@@ -0,0 +1,41 @@
+From ab6b1acdeed76899f8227c38ab7e7675c7673ff1 Mon Sep 17 00:00:00 2001
+From: Joe Slater <[email protected]>
+Date: Thu, 5 Aug 2021 09:23:48 -0700
+Subject: [oe-core][PATCH 1/1] pkgdata: increase command buffer size
+
+Make cmd LARGE_BUFFER_SIZE to avoid pathname truncation
+when install paths are longer than about 150 characters.
+
+Signed-off-by: Joe Slater <[email protected]>
+---
+ source/tools/pkgdata/pkgdata.cpp | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/source/tools/pkgdata/pkgdata.cpp

b/source/tools/pkgdata/pkgdata.cpp

meta/recipes-support/icu/icu/0001-pkgdata-increase-command-buffer-size.patch new file +6 -0
+index 5ab682e..d4b70ef 100644
+--- a/tools/pkgdata/pkgdata.cpp
++++ b/tools/pkgdata/pkgdata.cpp
+@@ -1131,17 +1131,17 @@ normal_symlink_mode:
+
+ static int32_t pkg_installLibrary(const char *installDir, const char

*targetDir, UBool noVersion) {

meta/recipes-support/icu/icu/0001-pkgdata-increase-command-buffer-size.patch new file +12 -0
+     int32_t result = 0;
+-    char cmd[SMALL_BUFFER_MAX_SIZE];
++    char cmd[LARGE_BUFFER_MAX_SIZE];
+
+     auto ret = snprintf(cmd,
+-            SMALL_BUFFER_MAX_SIZE,
++            LARGE_BUFFER_MAX_SIZE,
+             "cd %s && %s %s %s%s%s",
+             targetDir,
+             pkgDataFlags[INSTALL_CMD],
+             libFileNames[LIB_FILE_VERSION],
+             installDir, PKGDATA_FILE_SEP_STRING,

libFileNames[LIB_FILE_VERSION]);

meta/recipes-support/icu/icu/0001-pkgdata-increase-command-buffer-size.patch new file +9 -0
+     (void)ret;
+-    U_ASSERT(0 <= ret && ret < SMALL_BUFFER_MAX_SIZE);
++    U_ASSERT(0 <= ret && ret < LARGE_BUFFER_MAX_SIZE);
+
+     result = runCommand(cmd);
+
+--
+2.29.2
+
meta/recipes-support/icu/icu_69.1.bb +1 -1
index bfeea8d2f0..00c22372b5 100644
@@ -107,6 +107,7 @@ SRC_URI = "${BASE_SRC_URI};name=code \
            file://filter.json \
            file://fix-install-manx.patch \
            file://0001-icu-Added-armeb-support.patch \
+           file://0001-pkgdata-increase-command-buffer-size.patch \
            "
 
 SRC_URI_append_class-target = "\
--

2.29.2