tlshd/tags.c: printf format mismatch (%u with signed int)
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 50
- Forks
- 37
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 2
Description
In src/tlshd/tags.c:1436 the certificate version is printed with %u while the argument is a signed int (the return of gnutls_x509_crt_get_version(), already checked >= 0 at that point):
snprintf(version, sizeof(version), "%u", ret);
The value is non-negative here so behavior is fine in practice, but the format mismatch is reported by cppcheck (invalidPrintfArgType_uint) and is UB strictly speaking. Suggested fix: "%u", (unsigned)ret.
Happy to send a patch if contributions are accepted without an OCA; otherwise please consider this a report.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open src/tlshd/tags.c at line 1436 and inspect the certificate-version formatting after the non-negative check. Apply the suggested type-correctness fix, then run cppcheck to confirm invalidPrintfArgType_uint is no longer reported. Done means the format argument matches the conversion and the warning is resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- networking, security
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 90/100