8000 expr: gnu generates a division by zero when we don't · Issue #5576 · uutils/coreutils · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

expr: gnu generates a division by zero when we don't #5576

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

Closed
sylvestre opened this issue Nov 22, 2023 · 2 comments · Fixed by #5577
Closed

expr: gnu generates a division by zero when we don't #5576

sylvestre opened this issue Nov 22, 2023 · 2 comments · Fixed by #5577
Labels

Comments

@sylvestre
Copy link
Contributor

with GNU:

$ /usr/bin/expr  "85" "/" "983" ":" "83"
/usr/bin/expr: division by zero

With our implementation:

$ ./target/debug/coreutils expr  "85" "/" "983" ":" "83"  
42

Found by the fuzzer

@cobaweel
Copy link
Contributor

I'm gonna take a look.

@cobaweel
Copy link
Contributor

Seems like the problem has nothing to do with division and instead is about the regex match operator (:).

According to POSIX and the GNU manual, the regex on the right side of the operator needs to be read with an implicit ^ at the start, i.e., it should only match at the beginning of the string.

Indeed, running /usr/bin/expr abc : bc gives 0, but ./target/debug/coreutils expr abc : bc gives 2. The code does indeed seem to not prepend the ^. I'm working on a fix now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants
0