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

strton64() should always be used when parsing numeric CLI args #1419

Open
krader1961 opened this issue Oct 24, 2019 · 0 comments
Open

strton64() should always be used when parsing numeric CLI args #1419

krader1961 opened this issue Oct 24, 2019 · 0 comments

Comments

@krader1961
Copy link
Contributor

While working on issue #507 I noticed that there is inconsistency in how numeric CLI args are handled. In particular when the value is represented as bundled short options such as -123.

In some cases the value is parsed by AST function strton64() indirectly via optget(). That function supports alternative forms such as base#value which is not supported by more familiar libc functions such as strtol(). In some cases both functions are applied to the same argument. Which is a problem if the value is recognized by strton64() but not strtol(). In other cases only the forms recognized by strol() and related functions are allowed.

This is unlikely to be an issue in practice because few people will ever try to do something like kill -2#11 $pid as an alternative to kill -3 $pid. Nonetheless, for consistency strton64() should always be used. Obviously coupled with appropriate error and bounds checking.

This is to remind me to try and unify the CLI numeric argument handling around strton64().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant