nodejs/node · error
U_BUFFER_OVERFLOW_ERROR
U_BUFFER_OVERFLOW_ERROR
Error message
icupkg/makeTargetName(%s) target item name length %ld too long\n
What it means
makeTargetName composes target = treePart + id + suffix and checks the total against the caller's fixed-size buffer capacity; if targetLength >= capacity it prints the item name + length and sets *pErrorCode = U_BUFFER_OVERFLOW_ERROR (returns, does not exit). The capacity comes from sizeof() a local char[] at the call sites.
Source
Thrown at deps/icu-small/source/tools/toolutil/pkgitems.cpp:152
int32_t treeLength, suffixLength, targetLength;
// get the item basename
itemID=strrchr(itemName, '/');
if(itemID!=nullptr) {
++itemID;
} else {
itemID=itemName;
}
// build the target string
treeLength = static_cast<int32_t>(itemID - itemName);
if(idLength<0) {
idLength = static_cast<int32_t>(strlen(id));
}
suffixLength = static_cast<int32_t>(strlen(suffix));
targetLength=treeLength+idLength+suffixLength;
if(targetLength>=capacity) {
fprintf(stderr, "icupkg/makeTargetName(%s) target item name length %ld too long\n",
itemName, static_cast<long>(targetLength));
*pErrorCode=U_BUFFER_OVERFLOW_ERROR;
return;
}
memcpy(target, itemName, treeLength);
memcpy(target+treeLength, id, idLength);
memcpy(target+treeLength+idLength, suffix, suffixLength+1); // +1 includes the terminating NUL
}
static void
checkIDSuffix(const char *itemName, const char *id, int32_t idLength, const char *suffix,
CheckDependency check, void *context,
UErrorCode *pErrorCode) {
char target[200];
makeTargetName(itemName, id, idLength, suffix, target, static_cast<int32_t>(sizeof(target)), pErrorCode);
if(U_SUCCESS(*pErrorCode)) {
check(context, itemName, target);View on GitHub (pinned to 1b2de5e052)
Solutions
- Shorten the item/locale names in the source data, or restructure the resource tree to be shallower.
- Rebuild pkgitems with a larger target buffer at the call sites (sizeof target) if long names are legitimate.
- Audit the .dat for items with unexpectedly long names (`icupkg -l`).
- Validate name lengths before packaging and reject over-length entries upstream.
Example fix
// before (pkgitems.cpp call site uses a fixed local buffer) char target[256]; makeTargetName(itemName, id, idLen, ".res", target, (int32_t)sizeof(target), &errorCode); // after char target[1024]; // only if legitimately long names are required makeTargetName(itemName, id, idLen, ".res", target, (int32_t)sizeof(target), &errorCode);
Defensive patterns
Strategy: validation
Validate before calling
// reject items whose composed target name would overflow a reasonable bound
size_t treeLen = strnlen(itemName, 256), idLen = idLength >= 0 ? (size_t)idLength : strlen(id), sufLen = strlen(suffix);
if (treeLen + idLen + sufLen >= capacity) { *pErrorCode = U_BUFFER_OVERFLOW_ERROR; return; } Try / catch
// caller checks UErrorCode after makeTargetName (it sets the code, does not exit)
UErrorCode err = U_ZERO_ERROR;
makeTargetName(itemName, id, idLen, suffix, target, (int32_t)sizeof(target), &err);
if (U_FAILURE(err)) { /* log and skip this item; do not use target */ } Prevention
- Always check *pErrorCode after makeTargetName — it returns, it does not abort.
- Keep resource/locale tree paths shallow and names reasonably short.
- If long names are legitimate, enlarge the target buffer at the call site and rebuild.
- Audit .dat contents with `icupkg -l` for pathologically named items.
When it happens
Trigger: An item whose name (tree path + id + suffix like .res) exceeds the stack buffer size passed in. The check `if(targetLength>=capacity)` fires before the memcpy block.
Common situations: A locale/resource path with many path components, or an unusually long locale ID, exceeding the fixed target buffer; a .dat containing pathologically named items.
Related errors
- icupkg: udata_openSwapper(\"%s\") failed - %s\n
- U_MEMORY_ALLOCATION_ERROR
- U_INVALID_CHAR_FOUND
- U_BUFFER_OVERFLOW_ERROR
- missing list file\n
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/16ff7a2776e56ee5.
Report an issue: GitHub.