diff options
author | Simon Josefsson <simon@josefsson.org> | 2009-06-03 06:48:46 +0200 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2009-06-03 06:48:46 +0200 |
commit | a5e0d48f8b39580541d23173bef12b4ab9ebc74d (patch) | |
tree | e6e477c75f00de7d2274e60e84cf5b9416c18392 | |
parent | 74a79f645da522f3b2519bd98d6eab1fb81debf5 (diff) | |
download | gnutls-a5e0d48f8b39580541d23173bef12b4ab9ebc74d.tar.gz |
Reduce stack size.
-rw-r--r-- | lib/x509/output.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/x509/output.c b/lib/x509/output.c index e6951b2660..38200bb876 100644 --- a/lib/x509/output.c +++ b/lib/x509/output.c @@ -1836,24 +1836,43 @@ print_crq (gnutls_string * str, gnutls_x509_crq_t cert) } else if (strcmp (oid, "1.2.840.113549.1.9.7") == 0) { - char pass[1024]; - size_t pass_size = sizeof (pass); + char *pass; + size_t size; if (challenge) { - addf (str, + adds (str, "error: more than one Challenge password attribute\n"); continue; } - err = - gnutls_x509_crq_get_challenge_password (cert, pass, &pass_size); + err = gnutls_x509_crq_get_challenge_password (cert, NULL, &size); + if (err < 0) + { + addf (str, "error: get_challenge_password: %s\n", + gnutls_strerror (err)); + continue; + } + + size++; + + pass = gnutls_malloc (size); + if (!pass) + { + addf (str, "error: malloc: %s\n", + gnutls_strerror (GNUTLS_E_MEMORY_ERROR)); + continue; + } + + err = gnutls_x509_crq_get_challenge_password (cert, pass, &size); if (err < 0) addf (str, "error: get_challenge_password: %s\n", gnutls_strerror (err)); else addf (str, _("\t\tChallenge password: %s\n"), pass); + gnutls_free (pass); + challenge++; } else |