diff options
| author | Mattias Andrée <m@maandree.se> | 2026-05-15 01:22:19 +0200 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-05-15 01:22:19 +0200 |
| commit | 68d6804a43dca2749a68a557e67b98e6005ead83 (patch) | |
| tree | 9c4137a48cd37ea423578d1ac3df6e3953cb2156 /argon2/make_settings.c | |
| parent | Fix minor errors in the test and check that we are not writing out of bounds (diff) | |
| download | librecrypt-68d6804a43dca2749a68a557e67b98e6005ead83.tar.gz librecrypt-68d6804a43dca2749a68a557e67b98e6005ead83.tar.bz2 librecrypt-68d6804a43dca2749a68a557e67b98e6005ead83.tar.xz | |
Fix some minor issues
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'argon2/make_settings.c')
| -rw-r--r-- | argon2/make_settings.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/argon2/make_settings.c b/argon2/make_settings.c index 4354196..bac49a4 100644 --- a/argon2/make_settings.c +++ b/argon2/make_settings.c @@ -47,7 +47,8 @@ make_settings(char *out_buffer, size_t size, const char *algorithm, size_t memco algolen = p ? (size_t)(p - algorithm) : strlen(algorithm); if (algolen > 32u) /* just some small value absolute will fit all variants */ abort(); /* $covered$ */ - if (p++ && *p++ == 'v') { + if (p && p[1u] == 'v') { + p = &p[2u]; if (!strncmp(p, "=16", 3u) && (!p[3u] || p[3u] == '$')) version = "16"; else if (!strncmp(p, "=19", 3u) && (!p[3u] || p[3u] == '$')) @@ -81,7 +82,8 @@ make_settings(char *out_buffer, size_t size, const char *algorithm, size_t memco } else { ret += len = sizeof("*16") - 1u; min = size ? MIN(len, size - 1u) : 0u; - memcpy(out_buffer, "*16", min); + if (min) + memcpy(out_buffer, "*16", min); } out_buffer = &out_buffer[min]; size -= min; @@ -89,7 +91,8 @@ make_settings(char *out_buffer, size_t size, const char *algorithm, size_t memco /* Add tag size (size of hash result) */ ret += len = sizeof("$*32") - 1u; min = size ? MIN(len, size - 1u) : 0u; - memcpy(out_buffer, "$*32", min); + if (min) + memcpy(out_buffer, "$*32", min); out_buffer = &out_buffer[min]; size -= min; |
