Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid function names when printing OpenSSL errors #133

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Ignore the function name in OpenSSL errors
The use of the function name in errors has been abandoned in OpenSSL 3.
Profit to replace the use of sprintf with snprintf.
giacomini committed Jun 14, 2024
commit 8866b953bd725adf7d5f55a4b9eaa765ff58e202
12 changes: 6 additions & 6 deletions src/socklib/Server.cpp
Original file line number Diff line number Diff line change
@@ -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;
@@ -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) {
@@ -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);
}