[Asterisk-code-review] tcptls.c: Use memory BIOs to print openssl errors. (asterisk[16])

Sean Bright asteriskteam at digium.com
Tue May 3 15:28:14 CDT 2022


Sean Bright has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/18527 )


Change subject: tcptls.c: Use memory BIOs to print openssl errors.
......................................................................

tcptls.c: Use memory BIOs to print openssl errors.

This avoids the use of open_memstream() which may not be present.

Change-Id: I71fcc367899ccc0b504da4b36ccfabef39b275c0
---
M main/tcptls.c
1 file changed, 8 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/27/18527/1

diff --git a/main/tcptls.c b/main/tcptls.c
index b2756d1..fcb4d55 100644
--- a/main/tcptls.c
+++ b/main/tcptls.c
@@ -110,23 +110,23 @@
 
 static void write_openssl_error_to_log(void)
 {
-	FILE *fp;
+	BIO *mem;
 	char *buffer;
-	size_t length;
+	ssize_t length;
 
-	fp = open_memstream(&buffer, &length);
-	if (!fp) {
+	mem = BIO_new(BIO_s_mem());
+	if (!mem) {
 		return;
 	}
 
-	ERR_print_errors_fp(fp);
-	fclose(fp);
+	ERR_print_errors(mem);
 
-	if (length) {
+	length = BIO_get_mem_data(mem, &buffer);
+	if (length > 0) {
 		ast_log(LOG_ERROR, "%.*s\n", (int) length, buffer);
 	}
 
-	ast_free(buffer);
+	BIO_free(mem);
 }
 #endif
 

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18527
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I71fcc367899ccc0b504da4b36ccfabef39b275c0
Gerrit-Change-Number: 18527
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean at seanbright.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220503/6d208f0e/attachment-0001.html>


More information about the asterisk-code-review mailing list