From f797c7dc176c833e6aa412c557d7fedd59dc1124 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 5 Apr 2011 13:57:28 +0200 Subject: [PATCH] bad data on RESTORE can no longer crash the server but create a memory leak with some input string --- src/cluster.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index b57dd48c..783c658d 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -1140,8 +1140,10 @@ void restoreCommand(redisClient *c) { /* Finally create the object from the serialized dump and * store it at the specified key. */ - o = rdbLoadObject(data[0],fp); - if (o == NULL) { + if ((data[0] > 4 && data[0] < 9) || + data[0] > 11 || + (o = rdbLoadObject(data[0],fp)) == NULL) + { addReplyError(c,"Bad data format."); fclose(fp); return;