-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Potential fault at createDoubleObject #963
Comments
afcidk
added a commit
to afcidk/hiredis
that referenced
this issue
Jun 14, 2021
Resolves redis#963. Add additional check after `hi_malloc` for r->str when len+1 equals to 0.
afcidk
added a commit
to afcidk/hiredis
that referenced
this issue
Jun 14, 2021
Resolves redis#963. Add additional check to `hi_malloc` for `r->str` when len+1 equals to 0.
afcidk
added a commit
to afcidk/hiredis
that referenced
this issue
Jun 14, 2021
Resolves redis#963. Add additional check to `hi_malloc` for `r->str` when len+1 equals to 0.
Why would you want to specify len as -1 (it is unsigned). Or do you mean to say that the largest possible |
afcidk
added a commit
to afcidk/hiredis
that referenced
this issue
Nov 1, 2021
Resolves redis#963. Add additional check to `hi_malloc` for `r->str` when len equals to SIZE_MAX.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The potential fault occurs at the parameter
len
ofcreateDoubleObject
.From the function prototype, we can see that
len
is ofsize_t
type, which is known as an unsigned integer.hiredis/hiredis.c
Line 221 in b6f86f3
This function attempts to allocate some space for string-typed double value
dval
, and allocates one more byte for the null-terminating character for the string.hiredis/hiredis.c
Lines 228 to 233 in b6f86f3
When
len
is -1, the program allocates a space with size 0 forr->str
.According to man 3 malloc,
If
hi_malloc
does not return NULL, the program will crash in the followingmemcpy
, which passes maximum value of unsigned integer to the size ofmemcpy
.hiredis/hiredis.c
Line 240 in b6f86f3
Additional check to
len
parameter should be included increateDoubleObject
function.The text was updated successfully, but these errors were encountered: