]> git.saurik.com Git - redis.git/commitdiff
Fix NULL-termination of variable data in redis-benchmark
authorPieter Noordhuis <pcnoordhuis@gmail.com>
Thu, 16 Dec 2010 22:35:02 +0000 (23:35 +0100)
committerPieter Noordhuis <pcnoordhuis@gmail.com>
Thu, 16 Dec 2010 22:35:56 +0000 (23:35 +0100)
src/redis-benchmark.c

index c44b0ae453cd23b63eaf2dc819eaa27b9fa742e7..5e40c97b50a4f108fee81dba786ed506dd7245d7 100644 (file)
@@ -195,6 +195,11 @@ static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
             exit(1);
         }
         if (reply != NULL) {
+            if (reply == (void*)REDIS_REPLY_ERROR) {
+                fprintf(stderr,"Unexpected error reply, exiting...\n");
+                exit(1);
+            }
+
             if (config.donerequests < config.requests)
                 config.latency[config.donerequests++] = c->latency;
             clientDone(c);
@@ -454,8 +459,9 @@ int main(int argc, char **argv) {
         c->obuf = sdscatprintf(c->obuf,"*%d\r\n$4\r\nMSET\r\n", 11);
         {
             int i;
-            char *data = zmalloc(config.datasize+2);
+            char *data = zmalloc(config.datasize+1);
             memset(data,'x',config.datasize);
+            data[config.datasize] = '\0';
             for (i = 0; i < 10; i++) {
                 c->obuf = sdscatprintf(c->obuf,"$%d\r\n%s\r\n",config.datasize,data);
             }