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
5e707c66
Commit
5e707c66
authored
Aug 15, 2014
by
antirez
Browse files
Fix undefined behavior in ll2string().
The bug was found by @CAFxX, thanks! See issue #1940.
parent
65d47452
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/util.c
View file @
5e707c66
...
@@ -261,7 +261,11 @@ int ll2string(char* dst, size_t dstlen, long long svalue) {
...
@@ -261,7 +261,11 @@ int ll2string(char* dst, size_t dstlen, long long svalue) {
/* The main loop works with 64bit unsigned integers for simplicity, so
/* The main loop works with 64bit unsigned integers for simplicity, so
* we convert the number here and remember if it is negative. */
* we convert the number here and remember if it is negative. */
if
(
svalue
<
0
)
{
if
(
svalue
<
0
)
{
value
=
-
svalue
;
if
(
svalue
!=
LLONG_MIN
)
{
value
=
-
svalue
;
}
else
{
value
=
((
unsigned
long
long
)
LLONG_MAX
)
+
1
;
}
negative
=
1
;
negative
=
1
;
}
else
{
}
else
{
value
=
svalue
;
value
=
svalue
;
...
...
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