diff --git a/lib/crypt-pbkdf1-sha1.c b/lib/crypt-pbkdf1-sha1.c index bac867d7..10f8e662 100644 --- a/lib/crypt-pbkdf1-sha1.c +++ b/lib/crypt-pbkdf1-sha1.c @@ -148,6 +148,7 @@ crypt_sha1crypt_rn (const char *phrase, size_t phr_size, } sl = (size_t)(sp - setting); + assert (sl <= CRYPT_SHA1_SALT_LENGTH); /* * Now get to work... @@ -155,6 +156,7 @@ crypt_sha1crypt_rn (const char *phrase, size_t phr_size, */ dl = snprintf ((char *)output, out_size, "%.*s%s%lu", (int)sl, setting, magic, iterations); + assert (dl > 0); /* * Then hmac using as key, and repeat... */ diff --git a/lib/crypt-sha256.c b/lib/crypt-sha256.c index 6d21fa3c..9b32df52 100644 --- a/lib/crypt-sha256.c +++ b/lib/crypt-sha256.c @@ -261,6 +261,7 @@ crypt_sha256crypt_rn (const char *phrase, size_t phr_size, int n = snprintf (cp, SHA256_HASH_LENGTH - (sizeof (sha256_salt_prefix) - 1), "%s%zu$", sha256_rounds_prefix, rounds); + assert (n > 0); cp += n; } diff --git a/lib/crypt-sha512.c b/lib/crypt-sha512.c index 59ae9708..11aa0116 100644 --- a/lib/crypt-sha512.c +++ b/lib/crypt-sha512.c @@ -265,6 +265,7 @@ crypt_sha512crypt_rn (const char *phrase, size_t phr_size, int n = snprintf (cp, SHA512_HASH_LENGTH - (sizeof (sha512_salt_prefix) - 1), "%s%zu$", sha512_rounds_prefix, rounds); + assert (n > 0); cp += n; }