diff options
| author | Mattias Andrée <m@maandree.se> | 2026-05-17 21:02:39 +0200 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-05-17 21:02:39 +0200 |
| commit | 5fb2a5fe67521a452463e6b91cee406ec14c35a0 (patch) | |
| tree | f6be3a0c9086ef7122a7d5789818bdc7c0bb1081 /marshal.c | |
| parent | Update year (diff) | |
| download | libsha2-5fb2a5fe67521a452463e6b91cee406ec14c35a0.tar.gz libsha2-5fb2a5fe67521a452463e6b91cee406ec14c35a0.tar.bz2 libsha2-5fb2a5fe67521a452463e6b91cee406ec14c35a0.tar.xz | |
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'marshal.c')
| -rw-r--r-- | marshal.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -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); |
