aboutsummaryrefslogtreecommitdiffstats
path: root/unmarshal.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2019-02-10 13:48:27 +0100
committerMattias Andrée <maandree@kth.se>2019-02-10 13:48:27 +0100
commit7f5da97d1078fbeee7ef6125802ab2c7092079e0 (patch)
treeb29926c0c1c07ad3cfd543fa3a4eedf5a60b385a /unmarshal.c
parentAdd test cases (diff)
downloadlibsha2-7f5da97d1078fbeee7ef6125802ab2c7092079e0.tar.gz
libsha2-7f5da97d1078fbeee7ef6125802ab2c7092079e0.tar.bz2
libsha2-7f5da97d1078fbeee7ef6125802ab2c7092079e0.tar.xz
Minor fixes and tests
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--unmarshal.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/unmarshal.c b/unmarshal.c
index 6bbfaa0..909bdc2 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->message_size % state->chunk_size) {
+ if (bufsize - off < (state->message_size / 8) % state->chunk_size) {
errno = EINVAL;
return 0;
}
- memcpy(state->chunk, &buf[off], state->message_size % state->chunk_size);
- off += state->message_size % state->chunk_size;
+ memcpy(state->chunk, &buf[off], (state->message_size / 8) % state->chunk_size);
+ off += (state->message_size / 8) % state->chunk_size;
return off;
}