diff options
author | Mattias Andrée <maandree@kth.se> | 2019-02-10 20:57:56 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2019-02-10 20:57:56 +0100 |
commit | 15f132722cae63775dd7b2fef866d477c54c7b8e (patch) | |
tree | 27359241e0a1a0b6f304060bc0a9e7c9287efd06 /unmarshal.c | |
parent | First commit (diff) | |
download | libsha1-15f132722cae63775dd7b2fef866d477c54c7b8e.tar.gz libsha1-15f132722cae63775dd7b2fef866d477c54c7b8e.tar.bz2 libsha1-15f132722cae63775dd7b2fef866d477c54c7b8e.tar.xz |
Implement SHA-0 and remove .chunk_size1.0
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'unmarshal.c')
-rw-r--r-- | unmarshal.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/unmarshal.c b/unmarshal.c index e89a8dd..12eb652 100644 --- a/unmarshal.c +++ b/unmarshal.c @@ -41,19 +41,12 @@ libsha1_unmarshal(struct libsha1_state *restrict state, const void *restrict buf memcpy(state->h, &buf[off], sizeof(state->h)); off += sizeof(state->h); - if (bufsize - off < sizeof(size_t)) { + if (bufsize - off < (state->message_size / 8) % sizeof(state->chunk)) { errno = EINVAL; return 0; } - state->chunk_size = *(const size_t *)&buf[off]; - off += sizeof(size_t); - - if (bufsize - off < (state->message_size / 8) % state->chunk_size) { - errno = EINVAL; - return 0; - } - memcpy(state->chunk, &buf[off], (state->message_size / 8) % state->chunk_size); - off += (state->message_size / 8) % state->chunk_size; + memcpy(state->chunk, &buf[off], (state->message_size / 8) % sizeof(state->chunk)); + off += (state->message_size / 8) % sizeof(state->chunk); return off; } |