X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/eab0e26e03fa3c27a4e1172659cea32e1b83699e..b83e95830f45eb5e3b4e7c0a997d611f75f758b8:/src/rdb.c?ds=sidebyside diff --git a/src/rdb.c b/src/rdb.c index 1cfcd044..d2d54807 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -1,3 +1,6 @@ +#include "redis.h" +#include "lzf.h" /* LZF compression library */ + #include #include #include @@ -5,8 +8,6 @@ #include #include #include -#include "rdb.h" -#include "lzf.h" /* LZF compression library */ static int rdbWriteRaw(rio *rdb, void *p, size_t len) { if (rdb && rioWrite(rdb,p,len) == 0) @@ -947,19 +948,24 @@ int rdbLoad(char *filename) { rio rdb; fp = fopen(filename,"r"); - if (!fp) return REDIS_ERR; + if (!fp) { + errno = ENOENT; + return REDIS_ERR; + } rioInitWithFile(&rdb,fp); if (rioRead(&rdb,buf,9) == 0) goto eoferr; buf[9] = '\0'; if (memcmp(buf,"REDIS",5) != 0) { fclose(fp); redisLog(REDIS_WARNING,"Wrong signature trying to load DB from file"); + errno = EINVAL; return REDIS_ERR; } rdbver = atoi(buf+5); if (rdbver < 1 || rdbver > 2) { fclose(fp); redisLog(REDIS_WARNING,"Can't handle RDB format version %d",rdbver); + errno = EINVAL; return REDIS_ERR; }