[GH-ISSUE #2951] Rewrite common.c: isdec*() #1854

Closed
opened 2026-10-15 04:26:41 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @solardiz on GitHub (Dec 1, 2017).
Original GitHub issue: https://github.com/openwall/john/issues/2951

Originally assigned to: @jfoug on GitHub.

On invalid input, the isdec*() functions in common.c may cause signed integer overflow, then try to post-check for it, but the overflow itself is already UB. Those functions should be rewritten to manually work on the strings of digits - just loop over them making sure the characters are in fact digits and are not too numerous, and optionally allow a leading minus sign where needed. If we introduce a limit of at most 9 digits in there, then it would become safe for the callers to call atoi() next (like many currently do).

Originally created by @solardiz on GitHub (Dec 1, 2017). Original GitHub issue: https://github.com/openwall/john/issues/2951 Originally assigned to: @jfoug on GitHub. On invalid input, the `isdec*()` functions in `common.c` may cause signed integer overflow, then try to post-check for it, but the overflow itself is already UB. Those functions should be rewritten to manually work on the strings of digits - just loop over them making sure the characters are in fact digits and are not too numerous, and optionally allow a leading minus sign where needed. If we introduce a limit of at most 9 digits in there, then it would become safe for the callers to call `atoi()` next (like many currently do).
bsakaguchi 2026-10-15 04:26:41 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#1854
No description provided.