summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-01-04 09:10:54 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2017-01-04 10:17:17 +0100
commitf449ce8ea94ef2fc6d26547946dc7189feeea9cd (patch)
tree515cc639efb0f6f49e2c1a91001ceafbadc9960e
parent920abeb43b71af1704235ee2ec3d229820af1ceb (diff)
downloadgnutls-f449ce8ea94ef2fc6d26547946dc7189feeea9cd.tar.gz
_gnutls_pkcs12_string_to_key: avoid division by zero when salt_size = 0
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
-rw-r--r--lib/x509/pkcs12_encr.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/x509/pkcs12_encr.c b/lib/x509/pkcs12_encr.c
index 1114d7300a..557301a197 100644
--- a/lib/x509/pkcs12_encr.c
+++ b/lib/x509/pkcs12_encr.c
@@ -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) {