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

uniq(1): use strtonum to parse options #643

Closed

Conversation

daniel-tameling
Copy link
Contributor

Previously strtol was used and the result was directly cast to an int without checking for an overflow.
So one can do things like
echo 'hello\nbello' | uniq -s 4294967296
which is equivalent to
echo 'hello\nbello' | uniq -s 0
With the program aborts with:
uniq: character skip value is too large: 4294967296

Previously strtol was used and the result was directly cast to an int
without checking for an overflow. Use strtonum instead since it is
safer and tells us what went wrong.
@bsdimp
Copy link
Member

bsdimp commented Feb 9, 2023

This looks good to me.

@bsdimp
Copy link
Member

bsdimp commented Feb 25, 2023

Landed as e052829

@bsdimp bsdimp closed this Feb 25, 2023
freebsd-git pushed a commit that referenced this pull request Feb 25, 2023
Previously strtol was used and the result was directly cast to an int
without checking for an overflow. Use strtonum instead since it is
safer and tells us what went wrong.

Reviewed by: imp
Pull Request: #643
@daniel-tameling daniel-tameling deleted the bugfix-strtol-usage branch February 26, 2023 10:33
bsdjhb pushed a commit to bsdjhb/cheribsd that referenced this pull request Mar 29, 2023
Previously strtol was used and the result was directly cast to an int
without checking for an overflow. Use strtonum instead since it is
safer and tells us what went wrong.

Reviewed by: imp
Pull Request: freebsd/freebsd-src#643
@emaste emaste added the merged label Jun 12, 2023
freebsd-git pushed a commit that referenced this pull request Jan 17, 2024
Previously strtol was used and the result was directly cast to an int
without checking for an overflow. Use strtonum instead since it is
safer and tells us what went wrong.

Reviewed by: imp
Pull Request: #643

(cherry picked from commit e052829)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants