Skip to content

Commit

Permalink
Validate record on lookup if its checksum is requested
Browse files Browse the repository at this point in the history
  • Loading branch information
shaitan committed May 19, 2016
1 parent 7be0b64 commit e70c2e4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion example/eblob_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ static int blob_file_info(struct eblob_backend_config *c, void *state, struct dn
struct eblob_write_control wc;
struct dnet_ext_list elist;
static const size_t ehdr_size = sizeof(struct dnet_ext_list_hdr);
uint64_t offset, size;
uint64_t offset = 0, size = 0, record_offset = 0;
int fd, err;

dnet_ext_list_init(&elist);
Expand Down Expand Up @@ -796,6 +796,7 @@ static int blob_file_info(struct eblob_backend_config *c, void *state, struct dn
/* Take into an account extended header's len */
size -= ehdr_size;
offset += ehdr_size;
record_offset += sizeof(struct dnet_ext_list_hdr);
}

if (size == 0) {
Expand All @@ -805,6 +806,16 @@ static int blob_file_info(struct eblob_backend_config *c, void *state, struct dn
goto err_out_exit;
}

/* Validate record's data if its checksum is requested */
if (cmd->flags & DNET_FLAGS_CHECKSUM) {
wc.offset = record_offset;
wc.size = size;
err = eblob_verify_checksum(b, &key, &wc);
if (err) {
goto err_out_exit;
}
}

err = dnet_send_file_info_ts(state, cmd, fd, offset, size, &elist.timestamp, wc.flags);

err_out_exit:
Expand Down

0 comments on commit e70c2e4

Please sign in to comment.