On 16. 7. 25 21:34, dsahlb...@apache.org wrote:
Author: dsahlberg
Date: Wed Jul 16 19:34:43 2025
New Revision: 1927273
URL:http://svn.apache.org/viewvc?rev=1927273&view=rev
Log:
Followup to r1926972, tighten up the code slightly.
* buckets/ssl_buckets.c
(log_ssl_error): Skip an unnecessary copy of the error message to the stack
- the consumer anyway has to make a copy in the callback.
(ssl_need_client_cert): Decrease scope for err variable.
Review by: gstein (see GitHub PR#9)
Modified:
serf/trunk/buckets/ssl_buckets.c
Modified: serf/trunk/buckets/ssl_buckets.c
URL:http://svn.apache.org/viewvc/serf/trunk/buckets/ssl_buckets.c?rev=1927273&r1=1927272&r2=1927273&view=diff
==============================================================================
--- serf/trunk/buckets/ssl_buckets.c (original)
+++ serf/trunk/buckets/ssl_buckets.c Wed Jul 16 19:34:43 2025
@@ -362,9 +362,8 @@ static void log_ssl_error(serf_ssl_conte
while ((err = ERR_get_error())) {
if (err && ctx->error_callback) {
- char ebuf[256];
- ERR_error_string_n(err, ebuf, sizeof(ebuf));
- ctx->error_callback(ctx->error_baton, ctx->fatal_err, ebuf);
+ char *errstr = ERR_error_string(err, NULL);
+ ctx->error_callback(ctx->error_baton, ctx->fatal_err, errstr);
}
It would appear that this copy wasn't unnecessary after all.
https://docs.openssl.org/master/man3/ERR_error_string/
ERR_error_string() generates a human-readable string representing the
error code/e/, and places it at/buf/./buf/must be at least 256 bytes
long. If/buf/is*NULL*, the error string is placed in a static buffer.
Note that this function is not thread-safe and does no checks on the
size of the buffer; use ERR_error_string_n() instead.
"Not thread safe static buffer" is a non-starter. This hunk should be
reverted.
-- Brane