{"record":{"id":"88ff4f68fddafb7c","repo":"nodejs/node","slug":"s-d-s-n","errorCode":null,"errorMessage":"%s:%d: %s\\n","messagePattern":"%s:%d: %s\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"deps/icu-small/source/tools/toolutil/filetools.cpp","lineNumber":66,"sourceCode":"    if (filePath == nullptr || checkAgainst == nullptr) {\n        return false;\n    }\n\n    if (isDir == true) {\n#if U_HAVE_DIRENT_H\n        DIR *pDir = nullptr;\n        if ((pDir= opendir(checkAgainst)) != nullptr) {\n            DIR *subDirp = nullptr;\n            DIRENT *dirEntry = nullptr;\n\n            while ((dirEntry = readdir(pDir)) != nullptr) {\n                if (uprv_strcmp(dirEntry->d_name, SKIP1) != 0 && uprv_strcmp(dirEntry->d_name, SKIP2) != 0) {\n                    UErrorCode status = U_ZERO_ERROR;\n                    icu::CharString newpath(checkAgainst, -1, status);\n                    newpath.append(U_FILE_SEP_STRING, -1, status);\n                    newpath.append(dirEntry->d_name, -1, status);\n                    if (U_FAILURE(status)) {\n                        fprintf(stderr, \"%s:%d: %s\\n\", __FILE__, __LINE__, u_errorName(status));\n                        return false;\n                    }\n\n                    if ((subDirp = opendir(newpath.data())) != nullptr) {\n                        /* If this new path is a directory, make a recursive call with the newpath. */\n                        closedir(subDirp);\n                        isLatest = isFileModTimeLater(filePath, newpath.data(), isDir);\n                        if (!isLatest) {\n                            break;\n                        }\n                    } else {\n                        int32_t latest = whichFileModTimeIsLater(filePath, newpath.data());\n                        if (latest < 0 || latest == 2) {\n                            isLatest = false;\n                            break;\n                        }\n                    }\n","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/toolutil/filetools.cpp#L48-L84","documentation":"In isFileModTimeLater (filetools.cpp), while recursing through a directory, building the newpath via icu::CharString::append set the local UErrorCode to a failure (typically U_BUFFER_OVERFLOW_ERROR when the concatenated path is too long, or a memory error). The code prints __FILE__, __LINE__, and u_errorName(status), then returns false — treating the comparison as 'not latest', forcing a rebuild of the target.","triggerScenarios":"The directory entry name appended to checkAgainst overflows the CharString's internal buffer (very long path), or an allocation inside append fails. U_FAILURE(status) becomes true, newpath is invalid, and recursion aborts.","commonSituations":"A build tree with extremely long paths exceeding ICU toolutil's path limits; deeply nested resource directories; a corrupt dirent returning an overlong d_name.","solutions":["Shorten the directory tree depth/names so concatenated paths fit.","Move the build closer to the filesystem root to cut absolute path length.","Increase available memory if the failure was allocation-related (inspect u_errorName output).","Clean and rebuild to remove stale references to long paths."],"exampleFix":"// before: deep path triggers U_BUFFER_OVERFLOW_ERROR in CharString::append\n/home/user/.../very/deep/icu/data/...\n\n// after: shallower root\n/icu/data/...","handlingStrategy":"try-catch","validationCode":"// Mirror the toolutil check: bail if concatenating the entry overflows a CharString-sized buffer.\n#include <string.h>\n#include <limits.h>\nbool pathConcatFits(const char *dir, const char *name, size_t cap) {\n    size_t need = strlen(dir) + 1 + strlen(name) + 1;\n    return need < cap && need < PATH_MAX;\n}","typeGuard":null,"tryCatchPattern":"// ICU C++ pattern: check the UErrorCode after each CharString op, as toolutil does.\nicu::CharString p;\nUErrorCode status = U_ZERO_ERROR;\np.append(dir, -1, status);\np.append(U_FILE_SEP_STRING, -1, status);\np.append(name, -1, status);\nif (U_FAILURE(status)) { /* log u_errorName(status); skip this entry */ }","preventionTips":["Keep directory trees shallow so concatenated paths fit.","Always check U_FAILURE(status) after CharString::append.","Move the build root closer to / to shorten paths.","Log u_errorName(status) to distinguish overflow from allocation failure."],"tags":["icu","toolutil","filetools","build-tool","paths","buffer-overflow"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}