]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
_gnutls_pkcs12_string_to_key: avoid division by zero when salt_size = 0
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Wed, 4 Jan 2017 08:10:54 +0000 (09:10 +0100)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Wed, 4 Jan 2017 09:17:17 +0000 (10:17 +0100)
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
lib/x509/pkcs12_encr.c

index 1114d7300ae200d97a9d30bf56b5193fb6e838ee..557301a197fcdd05d22f2f8097abb506b9d3d9b7 100644 (file)
@@ -111,9 +111,15 @@ _gnutls_pkcs12_string_to_key(const mac_entry_st * me,
                goto cleanup;
        }
 
-       p = buf_i;
-       for (i = 0; i < 64; i++)
-               *p++ = salt[i % salt_size];
+
+       if (salt_size > 0) {
+               p = buf_i;
+               for (i = 0; i < 64; i++)
+                       *p++ = salt[i % salt_size];
+       } else {
+               memset(buf_i, 0, 64);
+               p = buf_i + 64;
+       }
 
        if (pw) {
                for (i = j = 0; i < p_size; i += 2) {