diff options
author | antirez <antirez@gmail.com> | 2015-11-28 09:05:41 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2015-11-28 09:06:32 +0100 |
commit | 4916d2051e4fcc3cba1b813557d7aa92ef7d5315 (patch) | |
tree | bcc3dc964477bf68fab42c20e6c56b64fc1f34b6 | |
parent | 47daa9b0c083432a6dcb8c3dbb0eca9b56d2bc51 (diff) | |
download | redis-4916d2051e4fcc3cba1b813557d7aa92ef7d5315.tar.gz |
fix sprintf and snprintf format string
There are some cases of printing unsigned integer with %d conversion
specificator and vice versa (signed integer with %u specificator).
Patch by Sergey Polovko. Backported to Redis from Disque.
-rw-r--r-- | src/debug.c | 2 | ||||
-rw-r--r-- | src/redis-cli.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/debug.c b/src/debug.c index d7da49099..c1918bd9c 100644 --- a/src/debug.c +++ b/src/debug.c @@ -518,7 +518,7 @@ void _serverAssertPrintClientInfo(client *c) { if (c->argv[j]->type == OBJ_STRING && sdsEncodedObject(c->argv[j])) { arg = (char*) c->argv[j]->ptr; } else { - snprintf(buf,sizeof(buf),"Object type: %d, encoding: %d", + snprintf(buf,sizeof(buf),"Object type: %u, encoding: %u", c->argv[j]->type, c->argv[j]->encoding); arg = buf; } diff --git a/src/redis-cli.c b/src/redis-cli.c index be37a9146..f70c05846 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -463,7 +463,7 @@ static sds cliFormatReplyTTY(redisReply *r, char *prefix) { _prefix = sdscat(sdsnew(prefix),_prefixlen); /* Setup prefix format for every entry */ - snprintf(_prefixfmt,sizeof(_prefixfmt),"%%s%%%dd) ",idxlen); + snprintf(_prefixfmt,sizeof(_prefixfmt),"%%s%%%ud) ",idxlen); for (i = 0; i < r->elements; i++) { /* Don't use the prefix for the first element, as the parent @@ -2050,7 +2050,7 @@ void bytesToHuman(char *s, long long n) { } if (n < 1024) { /* Bytes */ - sprintf(s,"%lluB",n); + sprintf(s,"%lldB",n); return; } else if (n < (1024*1024)) { d = (double)n/(1024); |