diff mbox series

[1/1] icu: increase command buffer size

Message ID 20230608171803.3728701-1-joe.slater@windriver.com
State New
Headers show
Series [1/1] icu: increase command buffer size | expand

Commit Message

Slater, Joseph June 8, 2023, 5:18 p.m. UTC
From: Joe Slater <joe.slater@windriver.com>

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 but this is not addressed here.

Signed-off-by: Joe Slater <joe.slater@windriver.com>
---
 ...pkgdata-increase-command-buffer-size.patch | 43 +++++++++++++++++++
 meta/recipes-support/icu/icu_72-1.bb          |  1 +
 2 files changed, 44 insertions(+)
 create mode 100644 meta/recipes-support/icu/icu/0001-pkgdata-increase-command-buffer-size.patch

Comments

Richard Purdie June 8, 2023, 9:20 p.m. UTC | #1
On Thu, 2023-06-08 at 10:18 -0700, Joe Slater via
lists.openembedded.org wrote:
> From: Joe Slater <joe.slater@windriver.com>
> 
> 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 but this is not addressed here.
> 
> Signed-off-by: Joe Slater <joe.slater@windriver.com>
> ---
>  ...pkgdata-increase-command-buffer-size.patch | 43 +++++++++++++++++++
>  meta/recipes-support/icu/icu_72-1.bb          |  1 +
>  2 files changed, 44 insertions(+)
>  create mode 100644 meta/recipes-support/icu/icu/0001-pkgdata-increase-command-buffer-size.patch

My worry with a patch like this is we could end up carrying it
indefinitely. This is the kind of patch which really does need to be
discussed with upstream...

Cheers,

Richard
diff mbox series

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..ea68e4be9f
--- /dev/null
+++ b/meta/recipes-support/icu/icu/0001-pkgdata-increase-command-buffer-size.patch
@@ -0,0 +1,43 @@ 
+From ab6b1acdeed76899f8227c38ab7e7675c7673ff1 Mon Sep 17 00:00:00 2001
+From: Joe Slater <joe.slater@windriver.com>
+Date: Thu, 5 Aug 2021 09:23:48 -0700
+Subject: [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.
+
+Upstream-Status: Pending
+
+Signed-off-by: Joe Slater <joe.slater@windriver.com>
+---
+ 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
+
diff --git a/meta/recipes-support/icu/icu_72-1.bb b/meta/recipes-support/icu/icu_72-1.bb
index c2eae5298f..af8f5da08c 100644
--- a/meta/recipes-support/icu/icu_72-1.bb
+++ b/meta/recipes-support/icu/icu_72-1.bb
@@ -106,6 +106,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 = "\