From 67b5763557cf5c2b0e5e8943071bc9b133bacbff Mon Sep 17 00:00:00 2001 From: Mike FABIAN Date: Sun, 22 Sep 2024 11:36:06 +0200 Subject: [PATCH] ICU-22912 fix coverity warning in gencnval.c See: https://unicode-org.atlassian.net/browse/ICU-22912 --- icu4c/source/tools/gencnval/gencnval.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/icu4c/source/tools/gencnval/gencnval.c b/icu4c/source/tools/gencnval/gencnval.c index ede356af743..e50eb231537 100644 --- a/icu4c/source/tools/gencnval/gencnval.c +++ b/icu4c/source/tools/gencnval/gencnval.c @@ -273,6 +273,12 @@ main(int argc, char* argv[]) { const char* sourcedir = options[SOURCEDIR].value; if (sourcedir != NULL && *sourcedir != 0) { + if (strlen(sourcedir) + strlen(path) + 2 > sizeof(pathBuf)) { + fprintf(stderr, + "The source file name is too long, it must be less than %d in bytes.\n", + (int) sizeof(pathBuf) - 1); + exit(U_ILLEGAL_ARGUMENT_ERROR); + } char *end; uprv_strcpy(pathBuf, sourcedir); end = uprv_strchr(pathBuf, 0);