diff options
| author | Mattias Andrée <m@maandree.se> | 2026-05-17 21:02:35 +0200 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-05-17 21:02:35 +0200 |
| commit | b5e063d63ecd3dbed1b68b1ea6961137d4f3f153 (patch) | |
| tree | fe2a848ab3208e9de8b362ba769535483472dbd6 /unmarshal.c | |
| parent | Update year (diff) | |
| download | libsha1-08aeb407be6eaa48e2d8ef57655c1eae647004c0.tar.gz libsha1-08aeb407be6eaa48e2d8ef57655c1eae647004c0.tar.bz2 libsha1-08aeb407be6eaa48e2d8ef57655c1eae647004c0.tar.xz | |
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'unmarshal.c')
| -rw-r--r-- | unmarshal.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/unmarshal.c b/unmarshal.c index c6668ac..6c52aa2 100644 --- a/unmarshal.c +++ b/unmarshal.c @@ -5,7 +5,7 @@ size_t libsha1_unmarshal(struct libsha1_state *restrict state, const void *restrict buf_, size_t bufsize) { - const char *restrict buf = buf_; + const unsigned char *restrict buf = buf_; size_t off = 0; int version; @@ -14,16 +14,16 @@ libsha1_unmarshal(struct libsha1_state *restrict state, const void *restrict buf return 0; } - version = *(const int *)buf; - if (version < 0 || version > 1) { /* version */ + memcpy(&version, buf, sizeof(int)); + if (version < 0 || version > 1) { errno = EINVAL; return 0; } off += sizeof(int); - state->algorithm = *(const enum libsha1_algorithm *)&buf[off]; + memcpy(&state->algorithm, &buf[off], sizeof(enum libsha1_algorithm)); off += sizeof(enum libsha1_algorithm); - state->message_size = *(const size_t *)&buf[off]; + memcpy(&state->message_size, &buf[off], sizeof(size_t)); off += sizeof(size_t); if (bufsize - off < sizeof(state->w) + sizeof(state->h)) { |
