diff options
author | Mattias Andrée <maandree@kth.se> | 2019-02-10 11:39:37 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2019-02-10 11:39:37 +0100 |
commit | 3c3a199f287faa7e3b714c6c7c39e5b35d61ef10 (patch) | |
tree | df1935465d6f35ec11c2e6174ddfbc842df0c073 /unmarshal.c | |
parent | Fix warnings (diff) | |
download | libsha2-3c3a199f287faa7e3b714c6c7c39e5b35d61ef10.tar.gz libsha2-3c3a199f287faa7e3b714c6c7c39e5b35d61ef10.tar.bz2 libsha2-3c3a199f287faa7e3b714c6c7c39e5b35d61ef10.tar.xz |
Marshal/Unmarshal: do no marshal unset bytes in the chunk
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'unmarshal.c')
-rw-r--r-- | unmarshal.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/unmarshal.c b/unmarshal.c index 315d556..6bbfaa0 100644 --- a/unmarshal.c +++ b/unmarshal.c @@ -74,12 +74,12 @@ libsha2_unmarshal(struct libsha2_state *restrict state, const char *restrict buf state->chunk_size = *(const size_t *)&buf[off]; off += sizeof(size_t); - if (bufsize - off < state->chunk_size) { + if (bufsize - off < state->message_size % state->chunk_size) { errno = EINVAL; return 0; } - memcpy(state->chunk, &buf[off], state->chunk_size); - off += state->chunk_size; + memcpy(state->chunk, &buf[off], state->message_size % state->chunk_size); + off += state->message_size % state->chunk_size; return off; } |