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 | |
| 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')
| -rw-r--r-- | argon2/hash.c | 5 | ||||
| -rw-r--r-- | argon2/make_settings.c | 9 |
2 files changed, 9 insertions, 5 deletions
diff --git a/argon2/hash.c b/argon2/hash.c index 9223e55..9c65e6a 100644 --- a/argon2/hash.c +++ b/argon2/hash.c @@ -100,8 +100,9 @@ librecrypt__argon2__hash(char *restrict out_buffer, size_t size, const char *phr type[1u] == 's' ? LIBAR2_ARGON2DS : type[0u] == 'i' ? LIBAR2_ARGON2I : LIBAR2_ARGON2D; - params.version = version[3u] == '9' ? LIBAR2_ARGON2_VERSION_13 : /* 19 = 0x13 = 1.3 */ - LIBAR2_ARGON2_VERSION_10; /* 16 = 0x10 = 1.0 */ + params.version = !*version ? LIBAR2_ARGON2_VERSION_10 : + version[3u] == '9' ? LIBAR2_ARGON2_VERSION_13 : /* 19 = 0x13 = 1.3 */ + LIBAR2_ARGON2_VERSION_10; /* 16 = 0x10 = 1.0 */ params.t_cost = (uint_least32_t)tcost; params.m_cost = (uint_least32_t)mcost; params.lanes = (uint_least32_t)lanes; 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; |
