-
Notifications
You must be signed in to change notification settings - Fork 227
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
SEGV in raster-interpret.c:1053 #1188
Comments
zdohnal
added a commit
to zdohnal/cups
that referenced
this issue
Mar 6, 2025
Input for `atoi()` can be bad number for argument `base` in `strtol()`, causing returning an incorrect pointer address and later segfault. Break out from function if the base is incorrect. Fixes OpenPrinting#1188
Hi @k-furman , I have created PR which fixes this, thank you so much for the analysis and the report! |
@zdohnal Don't forget to also apply any changes over in the libppd repository (I think that's the one that has inherited this code...) |
zdohnal
added a commit
to zdohnal/cups
that referenced
this issue
Mar 7, 2025
Input for `atoi()` can be bad number for argument `base` in `strtol()`, causing returning an incorrect pointer address and later segfault. Break out from function if the base is incorrect. Fixes OpenPrinting#1188
zdohnal
added a commit
to zdohnal/cups
that referenced
this issue
Mar 7, 2025
Input for `atoi()` can be bad number for argument `base` in `strtol()`, causing returning an incorrect pointer address and later segfault. Break out from function if the base is incorrect. Fixes OpenPrinting#1188
zdohnal
added a commit
that referenced
this issue
Mar 10, 2025
Input for atoi() can be bad number for argument base in strtol(), causing returning an incorrect pointer address and later segfault. Break out from function if the base is incorrect. Fixes #1188
zdohnal
added a commit
that referenced
this issue
Mar 10, 2025
Input for atoi() can be bad number for argument base in strtol(), causing returning an incorrect pointer address and later segfault. Break out from function if the base is incorrect. Fixes #1188
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
I have found a SEGV in
scan_ps()
function while fuzzing cups project with a harness from oss-fuzz.When I called the
_cupsRasterExecPS()
function with thecode
argument consisting of a string like this "701#", I got a SIGSEGV when it was calling thescan_ps()
function for the second time, specifically when it was dereferencing the*cur
pointer in thefor
loop.The problem is in the call to the
strtol()
function. We are trying to pass asbase
argument an int value recieved fromatoi()
func, which can be any int value, whilestrtol()
is waiting for a value between 2 and 36 or 0.Debugging this situation under gdb, i got these values before
strtol()
call:And these values after
strtol()
call:So, in this situation address of
cur
variable will be0xaaaaaaaaaaaaaaaa
, which is valid forif (!cur)
check, but is not valid forif (!*cur)
. After this,*ptr
address will be equal tocur
address, which is not quite correct.Idk how to fix it correctly, but i have some ideas for fixing it.
First idea is to check this value, and if it doesn't belong to 2..36 or 0, set base to 10:
Second idea - take the modulus of the
atoi()
value, but it should not be 1, so this will work:Third idea - include
errno.h
library and externerrno
variable, check errno for EINVAL and if it's true, setcur
ptr to NULL:To Reproduce
Steps to reproduce the behavior:
./fuzz_cups crash
System Information:
The text was updated successfully, but these errors were encountered: