aboutsummaryrefslogtreecommitdiff
path: root/Makefile-libbz2_so
diff options
context:
space:
mode:
authorNaveed Khan <naveed@digiscrypt.com>2026-06-26 21:58:00 +0530
committerMark Wielaard <mark@klomp.org>2026-06-30 11:48:14 +0200
commitaf35561761f36e2ce27484ca6d376326a80ebd1d (patch)
tree5caec82444c8a351fb2caac3d311803859dd53d9 /Makefile-libbz2_so
parentf153ef257a8e8901d8f8ed96fd1a2467806e8755 (diff)
downloadbzip2-master.tar.gz
bzip2-master.tar.bz2
bzip2-master.zip
bzip2recover: Use snprintf to build the output file nameHEADmaster
The per-block output file name is built in outFileName[BZ_MAX_FILENAME] with sprintf(split, "rec%5d", wrBlock+1). split is an interior pointer into outFileName, past any leading directory component of the input file name, so the bytes written here come right after attacker-influenced path data. The write is currently safe only by way of two non-local invariants: the input file name is rejected up front once strlen(argv[1]) reaches BZ_MAX_FILENAME-20, and the number of blocks is limited by BZ_MAX_HANDLED_BLOCKS so the formatted value stays at five digits. The comment on BZ_MAX_HANDLED_BLOCKS explicitly invites raising it, which would silently eat into that 20 byte margin. Bound the write with snprintf() using the space left after the directory prefix (BZ_MAX_FILENAME - ofs) so it can no longer overrun outFileName regardless of those invariants. This also removes the deprecated sprintf(), which recent compilers flag under -Wdeprecated-declarations. For valid input the result is unchanged: the "rec%5d" prefix always fits, so snprintf() writes exactly the same bytes. https://sourceware.org/bugzilla/show_bug.cgi?id=29280
Diffstat (limited to 'Makefile-libbz2_so')
0 files changed, 0 insertions, 0 deletions