Fix latent bugs: 3DES OOB decrypt length, format-string usage, missing test include#2
Merged
Merged
Conversation
The 3DES decrypt passed in->length - 10 + mdc as the ciphertext body length, reading and writing 2 bytes past the intended region when mdc=1 (OpenPGP MDC packets). Every sibling cipher (IDEA, CAST5, Blowfish, AES) uses - mdc, and the MDC ciphertext layout produced by pgp_3desencrypt makes - mdc the correct length. Mitigated in practice by buffer slack, but a genuine out-of-bounds access. Co-authored-by: BrainX <brainx@users.noreply.github.com>
fprintf(mbox, line) in logmail() and printw(ALLPINGERSURL) in the stats menu passed runtime/config-derived strings as format strings. Pass them as %s arguments instead. Co-authored-by: BrainX <brainx@users.noreply.github.com>
test-parse_yearmonthday.c calls memset() without including <string.h>, which fails to compile as an error under modern clang/gcc. Co-authored-by: BrainX <brainx@users.noreply.github.com>
brainx
marked this pull request as ready for review
June 17, 2026 15:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three real bugs found while auditing the modernized/vintage C sources. All are low-risk, localized fixes; no behavior change on the happy path.
1. Out-of-bounds length in
pgp_3desdecrypt(Src/pgpget.c)The 3DES decrypt passed
in->length - 10 + mdcas the ciphertext body length:When
mdc == 1(OpenPGP MDC packets, used by modern GnuPG/PGP) this reads 2 bytes past the valid ciphertext (in->data + 10 + mdconly holdsin->length - 10 - mdcbytes) and writes 2 bytes pastout->length. Evidence it's wrong:- mdc: IDEA (- 10 - mdc), CAST5 (- 10 - mdc), Blowfish (- 10 - mdc), AES (- 18 - mdc). 3DES is the lone outlier.pgp_3desencryptplaces the body at offset10 + mdcwith the decrypt buffer sizedin->length - 10 - mdc, so- mdcis the only consistent length.Fixed to
in->length - 10 - mdc. Mitigated in practice by the 128-byte buffer over-allocation (so sanitizers don't trip), but a genuine out-of-bounds access in crypto code.2. Format-string usage flagged by
-Wformat-security(Src/rem.c,Src/menustats.c)fprintf(mbox, line)inlogmail()andprintw(ALLPINGERSURL)in the stats menu passed runtime/config-derived strings directly as format strings. Changed tofprintf(mbox, "%s", line)andprintw("%s", ALLPINGERSURL). These were the only two-Wformat-securityhits in the tree.3. Missing
<string.h>in date-parse test (Src/tests/test-parse_yearmonthday.c)The test calls
memset()without including<string.h>, which is a hard compile error under modern clang/gcc (implicit function declaration). Added the include.Verification
mixmaster+mixremailercompile,0remaining-Wformat-securitywarnings across the tree.cc -DHAVE_SETENV Src/tests/test-parse_yearmonthday.c && ./a.out→OK.(previously failed to compile without an-includeworkaround).pgp_encrypt/pgp_decryptrecovers the plaintext (err=0), confirming the decrypt-length fix preserves correctness:pgp_3des_roundtrip.log
To show artifacts inline, enable in settings.