free the temporary buffers allocated by gnutls_x509_privkey_export_rsa_raw()
authorMartin Kaiser <wireshark@kaiser.cx>
Tue, 30 Dec 2014 18:33:16 +0000 (19:33 +0100)
committerMartin Kaiser <wireshark@kaiser.cx>
Tue, 30 Dec 2014 18:34:40 +0000 (18:34 +0000)
Bug: 10740
Change-Id: Idd4afab1bca6204d17c4bd4345661ec821f209e0
Reviewed-on: https://code.wireshark.org/review/6145
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Martin Kaiser <wireshark@kaiser.cx>
epan/dissectors/packet-ssl-utils.c

index e2558cd6b4642b72377916c953e520862feaed8e..2f5a974da8bb1433300493f8dca184affa9d8363 100644 (file)
@@ -3413,6 +3413,7 @@ ssl_privkey_to_sexp(struct gnutls_x509_privkey_int* priv_key)
 {
     gnutls_datum_t rsa_datum[RSA_PARS]; /* m, e, d, p, q, u */
     size_t         tmp_size;
+    gcry_error_t   gret;
     gcry_sexp_t    rsa_priv_key = NULL;
     gint           i;
     int            ret;
@@ -3450,7 +3451,10 @@ ssl_privkey_to_sexp(struct gnutls_x509_privkey_int* priv_key)
 
     /* convert each rsa parameter to mpi format*/
     for(i=0; i<RSA_PARS; i++) {
-      if (gcry_mpi_scan(&rsa_params[i], GCRYMPI_FMT_USG, rsa_datum[i].data, rsa_datum[i].size,&tmp_size) != 0) {
+      gret = gcry_mpi_scan(&rsa_params[i], GCRYMPI_FMT_USG, rsa_datum[i].data, rsa_datum[i].size,&tmp_size);
+      /* these buffers were allocated by gnutls_x509_privkey_export_rsa_raw() */
+      g_free(rsa_datum[i].data);
+      if (gret != 0) {
         ssl_debug_printf("ssl_load_key: can't convert m rsa param to int (size %d)\n", rsa_datum[i].size);
 #ifdef SSL_FAST
         g_free(rsa_params);