]> git.saurik.com Git - redis.git/blobdiff - redis.c
in rdbLoadDoubleValue now the buffer is nul terminated correctly. Thanks valgrind.
[redis.git] / redis.c
diff --git a/redis.c b/redis.c
index 75490f239f425cb8f04595070bd9cc16becd0243..302a2129d660101c61e425703c31faa2a4cc0499 100644 (file)
--- a/redis.c
+++ b/redis.c
@@ -27,7 +27,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define REDIS_VERSION "1.1.90"
+#define REDIS_VERSION "1.1.91"
 
 #include "fmacros.h"
 #include "config.h"
@@ -1802,7 +1802,7 @@ static void replicationFeedSlaves(list *slaves, struct redisCommand *cmd, int di
 
             lenobj = createObject(REDIS_STRING,
                 sdscatprintf(sdsempty(),"%lu\r\n",
-                    stringObjectLen(argv[j])));
+                    (unsigned long) stringObjectLen(argv[j])));
             lenobj->refcount = 0;
             outv[outc++] = lenobj;
         }
@@ -2019,7 +2019,7 @@ static void addReplyDouble(redisClient *c, double d) {
 
     snprintf(buf,sizeof(buf),"%.17g",d);
     addReplySds(c,sdscatprintf(sdsempty(),"$%lu\r\n%s\r\n",
-        strlen(buf),buf));
+        (unsigned long) strlen(buf),buf));
 }
 
 static void addReplyBulkLen(redisClient *c, robj *obj) {
@@ -2039,7 +2039,7 @@ static void addReplyBulkLen(redisClient *c, robj *obj) {
             len++;
         }
     }
-    addReplySds(c,sdscatprintf(sdsempty(),"$%lu\r\n",len));
+    addReplySds(c,sdscatprintf(sdsempty(),"$%lu\r\n",(unsigned long)len));
 }
 
 static void acceptHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
@@ -2823,6 +2823,7 @@ static int rdbLoadDoubleValue(FILE *fp, double *val) {
     case 253: *val = R_Nan; return 0;
     default:
         if (fread(buf,len,1,fp) == 0) return -1;
+        buf[len] = '\0';
         sscanf(buf, "%lg", val);
         return 0;
     }
@@ -5125,7 +5126,8 @@ static sds genRedisInfoString(void) {
 
 static void infoCommand(redisClient *c) {
     sds info = genRedisInfoString();
-    addReplySds(c,sdscatprintf(sdsempty(),"$%lu\r\n",sdslen(info)));
+    addReplySds(c,sdscatprintf(sdsempty(),"$%lu\r\n",
+        (unsigned long)sdslen(info)));
     addReplySds(c,info);
     addReply(c,shared.crlf);
 }
@@ -5668,7 +5670,7 @@ static void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **argv
 
         snprintf(seldb,sizeof(seldb),"%d",dictid);
         buf = sdscatprintf(buf,"*2\r\n$6\r\nSELECT\r\n$%lu\r\n%s\r\n",
-            strlen(seldb),seldb);
+            (unsigned long)strlen(seldb),seldb);
         server.appendseldb = dictid;
     }
 
@@ -5692,7 +5694,7 @@ static void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **argv
         robj *o = argv[j];
 
         o = getDecodedObject(o);
-        buf = sdscatprintf(buf,"$%lu\r\n",sdslen(o->ptr));
+        buf = sdscatprintf(buf,"$%lu\r\n",(unsigned long)sdslen(o->ptr));
         buf = sdscatlen(buf,o->ptr,sdslen(o->ptr));
         buf = sdscatlen(buf,"\r\n",2);
         decrRefCount(o);