Sfoglia il codice sorgente

nrpe 3.0.1 segfaults when key and/or cert are broken symlinks

Fix for issue #76

This seems to be somewhat platform specific. I was unable to
reproduce the problem on an openSUSE VM, but the segfault did
happen on a CentOS 5 VM.

The `ERR_error_string()` call seemed to be passing back an invalid
char pointer whether or not the second parameter was NULL. So I
put in a 120 character buffer and printed the error message from
there, instead of the returned pointer.
John C. Frickson 9 anni fa
parent
commit
e4ae64e3ac
2 ha cambiato i file con 6 aggiunte e 2 eliminazioni
  1. 1 0
      Changelog
  2. 5 2
      src/nrpe.c

+ 1 - 0
Changelog

@@ -20,6 +20,7 @@ FIXES
 - Add SOURCE_DATE_EPOCH specification support for reproducible builds. (Bas Couwenberg)
 - nrpe 3.0.1 allows TLSv1 and TLSv1.1 when I configure for TLSv1.2+ (John Frickson)
 - "Remote %s accepted a Version %s Packet", please add to debug (John Frickson)
+- nrpe 3.0.1 segfaults when key and/or cert are broken symlinks (John Frickson)
 
 
 3.0.1 - 2016-09-08

+ 5 - 2
src/nrpe.c

@@ -325,11 +325,14 @@ void init_ssl(void)
 	SSL_CTX_set_options(ctx, ssl_opts);
 
 	if (sslprm.cert_file != NULL) {
+		char	errstr[120] = { "" };
 		if (!SSL_CTX_use_certificate_file(ctx, sslprm.cert_file, SSL_FILETYPE_PEM)) {
 			SSL_CTX_free(ctx);
-			while ((x = ERR_get_error()) != 0)
+			while ((x = ERR_get_error()) != 0) {
+				ERR_error_string(x, errstr);
 				syslog(LOG_ERR, "Error: could not use certificate file %s : %s",
-					   sslprm.cert_file, ERR_error_string(x, NULL));
+					   sslprm.cert_file, errstr);
+			}
 			exit(STATE_CRITICAL);
 		}
 		if (!SSL_CTX_use_PrivateKey_file(ctx, sslprm.privatekey_file, SSL_FILETYPE_PEM)) {