changeset: 6619:eb94f64ad81a
user: Kevin McCarthy <[email protected]>
date: Mon Apr 11 12:45:25 2016 -0700
link: http://dev.mutt.org/hg/mutt/rev/eb94f64ad81a
Add null-terminator to BIO_get_mem_data() output.
It turns out the output isn't necessarily null-terminated.
diffs (26 lines):
diff -r 46f37be4afef -r eb94f64ad81a mutt_ssl.c
--- a/mutt_ssl.c Mon Apr 11 21:17:51 2016 +0200
+++ b/mutt_ssl.c Mon Apr 11 12:45:25 2016 -0700
@@ -549,12 +549,20 @@
#ifdef DEBUG
BIO *bio;
char *buf = NULL;
+ long buflen;
+ char *output;
if (! (bio = BIO_new (BIO_s_mem ())))
return;
ERR_print_errors (bio);
- if (BIO_get_mem_data (bio, &buf))
- dprint (1, (debugfile, "SSL error stack: %s\n", buf));
+ if ((buflen = BIO_get_mem_data (bio, &buf)) > 0)
+ {
+ output = safe_malloc (buflen + 1);
+ memcpy (output, buf, buflen);
+ output[buflen] = '\0';
+ dprint (1, (debugfile, "SSL error stack: %s\n", output));
+ FREE (&output);
+ }
BIO_free (bio);
#endif
}