Merged
Conversation
When a width specifier was given (e.g. %4095s), `str` was advanced by that width regardless of the actual token length. Parsing a short token on a small buffer would therefore walk past the end of the input, causing reads from unmapped memory and a kernel crash. Fix: clamp the advance to `strcspn(str, whitespace)` before moving the pointer forward. Applied to both the %s and numeric specifier paths.
…f with safe custom parser
- Replace sscanf-based line parsing with explicit parse_token /
parse_mount_line helpers that never over-advance past the token end
and properly decode octal-escape sequences (e.g. \040 for spaces).
- Add -h / --human-readable: sizes are shown in powers of 1024
(B / K / M / G / T) instead of raw 1K-block counts.
- Column header changes dynamically ('Size' vs '1K-blocks').
- Add event-driven long/short option parser (supports clusters, --, --opt=value, required/optional values) with explicit error codes. - No dynamic allocation and no internal static state. - Integrate df argument parsing using the new parser for -h/--human-readable and --help. - Keep strict handling of unexpected positional arguments for df.
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.
No description provided.