{"record":{"id":"2f080364f5902524","repo":"nodejs/node","slug":"u-illegal-argument-error-2f0803","errorCode":"U_ILLEGAL_ARGUMENT_ERROR","errorMessage":"genccode: filename too long\n","messagePattern":"genccode: filename too long\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/icu-small/source/tools/toolutil/pkg_genc.cpp","lineNumber":369,"sourceCode":"\n    getOutFilename(\n        filename,\n        destdir,\n        buffer.chars,\n        sizeof(buffer.chars),\n        entry,\n        sizeof(entry),\n        newSuffix,\n        optFilename);\n    out=T_FileStream_open(buffer.chars, \"w\");\n    if(out==nullptr) {\n        fprintf(stderr, \"genccode: unable to open output file %s\\n\", buffer.chars);\n        exit(U_FILE_ACCESS_ERROR);\n    }\n\n    if (outFilePath != nullptr) {\n        if (uprv_strlen(buffer.chars) >= outFilePathCapacity) {\n            fprintf(stderr, \"genccode: filename too long\\n\");\n            exit(U_ILLEGAL_ARGUMENT_ERROR);\n        }\n        uprv_strcpy(outFilePath, buffer.chars);\n#if defined (WINDOWS_WITH_GNUC) && U_PLATFORM != U_PF_CYGWIN\n        /* Need to fix the file separator character when using MinGW. */\n        swapFileSepChar(outFilePath, U_FILE_SEP_CHAR, '/');\n#endif\n    }\n\n    if(optEntryPoint != nullptr) {\n        uprv_strcpy(entry, optEntryPoint);\n        uprv_strcat(entry, \"_dat\");\n    }\n\n    /* turn dashes or dots in the entry name into underscores */\n    length=uprv_strlen(entry);\n    for(i=0; i<length; ++i) {\n        if(entry[i]=='-' || entry[i]=='.') {","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/toolutil/pkg_genc.cpp#L351-L387","documentation":"Thrown by genccode's writeAssemblyCode when the computed output filename length is greater than or equal to the caller-provided outFilePathCapacity. This is a buffer-safety guard: the resolved path would not fit in the caller's outFilePath buffer, so it aborts before copying.","triggerScenarios":"When outFilePath != nullptr, the code checks uprv_strlen(buffer.chars) >= outFilePathCapacity before uprv_strcpy. Failure means the path (destdir + name + suffix) is too long for the receiving buffer.","commonSituations":"Very deep build directory trees; very long ICU data filenames; deeply nested absolute paths on Windows; a caller passing a too-small buffer; symlink-heavy paths that expand.","solutions":["Shorten the destination directory path (-d) to reduce total length.","Increase the outFilePath buffer size in the calling code (the build system / Makefile).","Move the build root closer to the filesystem root to trim path depth.","Use relative paths where the build system allows."],"exampleFix":"// before (caller)\nchar outFilePath[64];\nwriteAssemblyCode(..., outFilePath, sizeof(outFilePath)); // too short\n\n// after\nchar outFilePath[PATH_MAX];\nwriteAssemblyCode(..., outFilePath, sizeof(outFilePath));","handlingStrategy":"validation","validationCode":"// Before calling writeAssemblyCode, ensure your outFilePath buffer is large\n// enough for any plausible output path.\n#include <climits>   // PATH_MAX\n#include <cstring>\nbool pathBufferAdequate(size_t cap, const char* destdir, const char* name) {\n    size_t need = std::strlen(destdir) + std::strlen(name) + 8; // sep + suffix + slop\n    return cap > need && cap >= PATH_MAX;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Allocate outFilePath with at least PATH_MAX bytes in the calling code.","Keep the -d destdir short to minimize total path length.","Validate the computed path length before passing the buffer to genccode.","Prefer relative build paths where the build system supports them."],"tags":["icu","genccode","buffer-overflow","path-length","build-tool"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}