From 5fb2a5fe67521a452463e6b91cee406ec14c35a0 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 17 May 2026 21:02:39 +0200 Subject: Fix mistakes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- marshal.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'marshal.c') diff --git a/marshal.c b/marshal.c index 7596c03..d5ceb28 100644 --- a/marshal.c +++ b/marshal.c @@ -5,17 +5,17 @@ size_t libsha2_marshal(const struct libsha2_state *restrict state, void *restrict buf_) { - char *restrict buf = buf_; + unsigned char *restrict buf = buf_; size_t off = 0; if (buf) - *(int *)buf = 1; /* version */ + memcpy(buf, &(int){1}, sizeof(int)); off += sizeof(int); if (buf) - *(enum libsha2_algorithm *)&buf[off] = state->algorithm; + memcpy(&buf[off], &state->algorithm, sizeof(enum libsha2_algorithm)); off += sizeof(enum libsha2_algorithm); if (buf) - *(size_t *)&buf[off] = state->message_size; + memcpy(&buf[off], &state->message_size, sizeof(size_t)); off += sizeof(size_t); if (state->algorithm <= LIBSHA2_256) { @@ -35,7 +35,7 @@ libsha2_marshal(const struct libsha2_state *restrict state, void *restrict buf_) } if (buf) - *(size_t *)&buf[off] = state->chunk_size; + memcpy(&buf[off], &state->chunk_size, sizeof(size_t)); off += sizeof(size_t); if (buf) memcpy(&buf[off], state->chunk, (state->message_size / 8) % state->chunk_size); -- cgit v1.3.1