aboutsummaryrefslogtreecommitdiffstats
path: root/unmarshal.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-05-17 21:02:35 +0200
committerMattias Andrée <m@maandree.se>2026-05-17 21:02:35 +0200
commitb5e063d63ecd3dbed1b68b1ea6961137d4f3f153 (patch)
treefe2a848ab3208e9de8b362ba769535483472dbd6 /unmarshal.c
parentUpdate year (diff)
downloadlibsha1-b5e063d63ecd3dbed1b68b1ea6961137d4f3f153.tar.gz
libsha1-b5e063d63ecd3dbed1b68b1ea6961137d4f3f153.tar.bz2
libsha1-b5e063d63ecd3dbed1b68b1ea6961137d4f3f153.tar.xz
Fix mistakesHEAD1.1.6master
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
-rw-r--r--unmarshal.c10
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)) {