Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
e1dc9790
Unverified
Commit
e1dc9790
authored
Aug 08, 2021
by
Binbin
Committed by
GitHub
Aug 08, 2021
Browse files
sds.c: Fix potential overflow in sdsll2str. (#8910)
Fixes an undefined behavior, same way as our `ll2string` does.
parent
563ba7a3
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sds.c
View file @
e1dc9790
...
...
@@ -553,7 +553,17 @@ int sdsll2str(char *s, long long value) {
/* Generate the string representation, this method produces
* a reversed string. */
v
=
(
value
<
0
)
?
-
value
:
value
;
if
(
value
<
0
)
{
/* Since v is unsigned, if value==LLONG_MIN, -LLONG_MIN will overflow. */
if
(
value
!=
LLONG_MIN
)
{
v
=
-
value
;
}
else
{
v
=
((
unsigned
long
long
)
LLONG_MAX
)
+
1
;
}
}
else
{
v
=
value
;
}
p
=
s
;
do
{
*
p
++
=
'0'
+
(
v
%
10
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment