diff options
author | antirez <antirez@gmail.com> | 2014-08-15 15:48:15 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-08-15 15:48:15 +0200 |
commit | c951c3ee5a12110f1c0c1270c45ab663c04e0f77 (patch) | |
tree | 516dca479d0d3e55e198e90821c681356dc40a23 /src/util.c | |
parent | 78a012d81a0f487b92b2b79a91de1f28697100e8 (diff) | |
download | redis-c951c3ee5a12110f1c0c1270c45ab663c04e0f77.tar.gz |
Fix undefined behavior in ll2string().
The bug was found by @CAFxX, thanks!
See issue #1940.
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/util.c b/src/util.c index a0bb2b84c..1b1798658 100644 --- a/src/util.c +++ b/src/util.c @@ -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 * we convert the number here and remember if it is negative. */ if (svalue < 0) { - value = -svalue; + if (svalue != LLONG_MIN) { + value = -svalue; + } else { + value = ((unsigned long long) LLONG_MAX)+1; + } negative = 1; } else { value = svalue; |