Skip to content

Commit

Permalink
ICU-22813 Rise the size of the buffers used for the command strings a…
Browse files Browse the repository at this point in the history
…t pkgdata

The tool pkgdata uses snprintf() to build the strings of the commands that
will execute later during the install process. But the maximum size of this
buffers is not enough when there is a long path.

This has caused issues on some CI systems that use very long paths, causing
the install process to produce a wrong result.

The maximum path on Linux is 4096 (defined as PATH_MAX at <linux/limits.h>)
So the size of SMALL_BUFFER_MAX_SIZE should be 4096 to avoid errors related
to truncated paths.
  • Loading branch information
clopez authored and markusicu committed Jul 19, 2024
1 parent 4acb472 commit 8ca6bc7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions icu4c/source/tools/pkgdata/pkgdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ static int32_t pkg_createSymLinks(const char *targetDir, UBool specialHandling)

static int32_t pkg_installLibrary(const char *installDir, const char *targetDir, UBool noVersion) {
int32_t result = 0;
char cmd[SMALL_BUFFER_MAX_SIZE * 2];
char cmd[LARGE_BUFFER_MAX_SIZE];

auto ret = snprintf(cmd,
sizeof(cmd),
Expand Down Expand Up @@ -1211,7 +1211,7 @@ static int32_t pkg_installLibrary(const char *installDir, const char *targetDir,

static int32_t pkg_installCommonMode(const char *installDir, const char *fileName) {
int32_t result = 0;
char cmd[SMALL_BUFFER_MAX_SIZE] = "";
char cmd[LARGE_BUFFER_MAX_SIZE] = "";

if (!T_FileStream_file_exists(installDir)) {
UErrorCode status = U_ZERO_ERROR;
Expand Down Expand Up @@ -1243,7 +1243,7 @@ static int32_t pkg_installCommonMode(const char *installDir, const char *fileNam
#endif
static int32_t pkg_installFileMode(const char *installDir, const char *srcDir, const char *fileListName) {
int32_t result = 0;
char cmd[SMALL_BUFFER_MAX_SIZE] = "";
char cmd[LARGE_BUFFER_MAX_SIZE] = "";

if (!T_FileStream_file_exists(installDir)) {
UErrorCode status = U_ZERO_ERROR;
Expand Down
5 changes: 2 additions & 3 deletions icu4c/source/tools/toolutil/pkg_genc.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@
#define PKGDATA_FILE_SEP_STRING U_FILE_SEP_STRING
#endif

#define LARGE_BUFFER_MAX_SIZE 2048
#define SMALL_BUFFER_MAX_SIZE 512
#define SMALL_BUFFER_FLAG_NAMES 32
#define LARGE_BUFFER_MAX_SIZE 16384
#define SMALL_BUFFER_MAX_SIZE 4096
#define BUFFER_PADDING_SIZE 20

/** End platform defines **/
Expand Down

0 comments on commit 8ca6bc7

Please sign in to comment.