{"record":{"id":"7e43e3367b542288","repo":"nodejs/node","slug":"u-buffer-overflow-error","errorCode":"U_BUFFER_OVERFLOW_ERROR","errorMessage":"pathname too long: \\\"%s\\\"\\n","messagePattern":"pathname too long: \\\\\"(.+?)\\\\\"\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/icu-small/source/tools/toolutil/package.cpp","lineNumber":258,"sourceCode":"        if(*t==U_FILE_SEP_CHAR || *t==U_FILE_ALT_SEP_CHAR) {\n            *t=U_TREE_ENTRY_SEP_CHAR;\n        }\n    }\n}\n#endif\n\n/*\n * Prepend the path (if any) to the name and run the name through treeToName().\n */\nstatic void\nmakeFullFilename(const char *path, const char *name,\n                 char *filename, int32_t capacity) {\n    char *s;\n\n    // prepend the path unless nullptr or empty\n    if(path!=nullptr && path[0]!=0) {\n        if (static_cast<int32_t>(strlen(path) + 1) >= capacity) {\n            fprintf(stderr, \"pathname too long: \\\"%s\\\"\\n\", path);\n            exit(U_BUFFER_OVERFLOW_ERROR);\n        }\n        strcpy(filename, path);\n\n        // make sure the path ends with a file separator\n        s=strchr(filename, 0);\n        if(*(s-1)!=U_FILE_SEP_CHAR && *(s-1)!=U_FILE_ALT_SEP_CHAR) {\n            *s++=U_FILE_SEP_CHAR;\n        }\n    } else {\n        s=filename;\n    }\n\n    // turn the name into a filename, turn tree separators into file separators\n    if (static_cast<int32_t>((s - filename) + strlen(name)) >= capacity) {\n        fprintf(stderr, \"path/filename too long: \\\"%s%s\\\"\\n\", filename, name);\n        exit(U_BUFFER_OVERFLOW_ERROR);\n    }","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/toolutil/package.cpp#L240-L276","documentation":"Thrown by makeFullFilename() when prepending a directory path to a filename and the resulting path (strlen(path) + 1 for the null terminator) would exceed or fill the destination buffer capacity. This is a path-length guard on a fixed-size char array (typically 1024 bytes) used for constructing full file paths during package item I/O.","triggerScenarios":"Calling readFile(), writePackage(), or any function that calls makeFullFilename() with a path argument whose strlen(path) + 1 >= capacity (1024 for readFile's local buffer). This occurs when the base directory path alone is too long for the filename buffer.","commonSituations":"Deeply nested build output directories; ICU data staged under very long temporary paths (e.g. CI build sandboxes with hashed paths); running on systems where the source tree has many directory levels.","solutions":["Shorten or flatten the directory path passed as the 'path' argument to icupkg or Package methods.","Use a working directory closer to the filesystem root and pass shorter relative paths.","Move the ICU data directory to a shorter absolute path."],"exampleFix":"// before\nicupkg -a /very/long/build/sandbox/hash123abc/path/to/output/dir\n// after\ncd /tmp && icupkg -a ./out","handlingStrategy":"validation","validationCode":"// Validate path length before calling icupkg with -a or output paths\n#include <cstring>\nbool isPathLengthSafe(const char* path, int32_t capacity = 1024) {\n    return path == nullptr || (static_cast<int32_t>(strlen(path) + 1) < capacity);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep ICU build and staging directories short and close to the filesystem root.","Avoid deeply nested temporary paths in CI environments.","Use relative paths from a sensible working directory."],"tags":["icu","icupkg","path-length","buffer-overflow","filesystem"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}