Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error handling for limits of byte-oriented command line args #1464

Open
brson opened this issue Jan 25, 2024 · 2 comments
Open

Add error handling for limits of byte-oriented command line args #1464

brson opened this issue Jan 25, 2024 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@brson
Copy link
Contributor

brson commented Jan 25, 2024

Some command line arguments have error handling for cases where the arguments are outside of reasonable limits. Several do not. Here are some that I see offhand:

  • --cache-grid - Extremely large values hit an intCast assertion. Unreasonably large values are accepted (1000000GB).
  • --cache-accounts - small values cause "unreachable" assertions, large values intCast
  • --cache-transfers - ditto
@brson
Copy link
Contributor Author

brson commented Jan 25, 2024

Note that some of the existing error handling occurs in main.zig, some in cli.zig. It seems reasonable to decide on one place.

@brson brson added good first issue Good for newcomers enhancement New feature or request labels Jan 25, 2024
@matklad
Copy link
Member

matklad commented Jan 25, 2024

Note that some of the existing error handling occurs in main.zig, some in cli.zig. It seems reasonable to decide on one place.

error handling (printing a nice message and exiting the process) should occur in cli.zig.

However, it’s generally a good idea to assert in main (or even at the deepest layer where the value of a particular argument penetrates), that the value is reasonable, as a defense in depth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants