aboutsummaryrefslogtreecommitdiffstats
path: root/marshal.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2019-02-10 11:39:37 +0100
committerMattias Andrée <maandree@kth.se>2019-02-10 11:39:37 +0100
commit3c3a199f287faa7e3b714c6c7c39e5b35d61ef10 (patch)
treedf1935465d6f35ec11c2e6174ddfbc842df0c073 /marshal.c
parentFix warnings (diff)
downloadlibsha2-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 'marshal.c')
-rw-r--r--marshal.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/marshal.c b/marshal.c
index 75a8749..cae5b20 100644
--- a/marshal.c
+++ b/marshal.c
@@ -50,8 +50,8 @@ libsha2_marshal(const struct libsha2_state *restrict state, char *restrict buf)
*(size_t *)&buf[off] = state->chunk_size;
off += sizeof(size_t);
if (buf)
- memcpy(&buf[off], state->chunk, state->chunk_size);
- off += state->chunk_size;
+ memcpy(&buf[off], state->chunk, state->message_size % state->chunk_size);
+ off += state->message_size % state->chunk_size;
return off;
}