summaryrefslogtreecommitdiff
path: root/contrib/apps/httpserver
diff options
context:
space:
mode:
authorAristo Chen <[email protected]>2026-05-26 07:03:32 +0000
committerTom Rini <[email protected]>2026-06-11 12:00:46 -0600
commit759968136d68ba178904313c38ad1003525c58ac (patch)
tree076cd2e468115e40c42c9476740ed43141b7251f /contrib/apps/httpserver
parent987907ae4bcc5d6055bdf7d318a3edf53e14d5fa (diff)
tools: mkimage: fix get_basename crash on paths with dotted directories
The get_basename() helper in tools/fit_image.c searches the entire input path for the last '/' and the last '.' independently. When the last '.' falls at an offset earlier than the last '/' (for example "./mydt", "a.b/c", or "sub.d/leaf"), 'end' points before 'start' and the computed length is negative. The subsequent size check uses signed comparison so the negative value passes through unchanged, and memcpy() is then called with that length implicitly cast to size_t, which segfaults. Restrict the dot search to the substring that follows the last slash so that only an extension in the filename component can become the end of the basename. This matches the function's stated intent of stripping an extension from the leaf, and keeps the existing behaviour for typical inputs such as "arch/arm/dts/foo.dtb". Reproducer that previously segfaulted and now produces a valid image: echo dummy > kernel.bin echo dummy > ./mydt ./tools/mkimage -f auto -A arm -O linux -T kernel -C none \ -a 0x80000000 -e 0x80000000 -n test \ -d kernel.bin -b ./mydt out.itb Signed-off-by: Aristo Chen <[email protected]> Reviewed-by: Quentin Schulz <[email protected]>
Diffstat (limited to 'contrib/apps/httpserver')
0 files changed, 0 insertions, 0 deletions