Skip to content

Commit

Permalink
Ignore the function name in OpenSSL errors
Browse files Browse the repository at this point in the history
The use of the function name in errors has been abandoned in OpenSSL 3.
Profit to replace the use of sprintf with snprintf.
  • Loading branch information
giacomini committed Jun 14, 2024
1 parent cd5c735 commit 8866b95
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/socklib/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,8 @@ void GSISocketServer::SetErrorOpenSSL(const std::string &err)

while( ERR_peek_error() ){

char error_msg_buf[512];
std::size_t const error_msg_buf_size = 512;
char error_msg_buf[error_msg_buf_size];

const char *filename;
int lineno;
Expand All @@ -729,7 +730,6 @@ void GSISocketServer::SetErrorOpenSSL(const std::string &err)
long error_code = ERR_get_error_line_data(&filename, &lineno, &data, &flags);

const char *lib = ERR_lib_error_string(error_code);
const char *func = ERR_func_error_string(error_code);
const char *error_reason = ERR_reason_error_string(error_code);

if (lib == NULL) {
Expand All @@ -741,11 +741,11 @@ void GSISocketServer::SetErrorOpenSSL(const std::string &err)
}
}

sprintf(error_msg_buf,
"%s %s [err:%lu,lib:%s,func:%s(file: %s+%d)]",
snprintf(error_msg_buf, error_msg_buf_size,
"%s %s [err:%lu,lib:%s,file:%s+%d]",
(error_reason) ? error_reason : "",
(data) ? data : "",
error_code,lib,func,filename,lineno);
(data && (flags & ERR_TXT_STRING)) ? data : "",
error_code,lib,filename,lineno);

openssl_errors.push_back(error_msg_buf);
}
Expand Down

0 comments on commit 8866b95

Please sign in to comment.