From: Jonathan Dieter Date: Wed, 30 May 2018 11:13:59 +0000 (+0300) Subject: We now verify whether options are valid for reading or writing X-Git-Tag: archive/raspbian/1.1.9+ds1-1+rpi1~1^2~269 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=23c2e77349ea8441cdbc139d32e511bff4c5dc9e;p=zchunk.git We now verify whether options are valid for reading or writing Signed-off-by: Jonathan Dieter --- diff --git a/src/lib/header.c b/src/lib/header.c index 5300d7d..b727b97 100644 --- a/src/lib/header.c +++ b/src/lib/header.c @@ -264,7 +264,7 @@ int read_preface(zckCtx *zck) { /* Read and initialize compression type */ if(!compint_to_int(&tmp, header+length, &length, max_length)) return False; - if(!zck_set_ioption(zck, ZCK_COMP_TYPE, tmp)) + if(!comp_ioption(zck, ZCK_COMP_TYPE, tmp)) return False; if(!zck_comp_init(zck)) return False; diff --git a/src/lib/index/index_read.c b/src/lib/index/index_read.c index a5d18d7..431f09c 100644 --- a/src/lib/index/index_read.c +++ b/src/lib/index/index_read.c @@ -40,7 +40,7 @@ int zck_index_read(zckCtx *zck, char *data, size_t size, size_t max_length) { int hash_type; if(!compint_to_int(&hash_type, data + length, &length, max_length)) return False; - if(!zck_set_ioption(zck, ZCK_HASH_CHUNK_TYPE, hash_type)) + if(!set_chunk_hash_type(zck, hash_type)) return False; /* Read number of index entries */ diff --git a/src/lib/zck.c b/src/lib/zck.c index a9cec56..4279f3b 100644 --- a/src/lib/zck.c +++ b/src/lib/zck.c @@ -136,6 +136,7 @@ int PUBLIC zck_set_soption(zckCtx *zck, zck_soption option, const void *value, /* Compression options */ } else if(option < 2000) { + VALIDATE_WRITE(zck); return comp_soption(zck, option, value, length); /* Unknown options */ @@ -403,7 +404,7 @@ int zck_import_dict(zckCtx *zck) { if(!zck_comp_reset(zck)) return False; zck_log(ZCK_LOG_DEBUG, "Setting dict\n"); - if(!zck_set_soption(zck, ZCK_COMP_DICT, data, size)) + if(!comp_soption(zck, ZCK_COMP_DICT, data, size)) return False; free(data); if(!zck_comp_init(zck))