Преглед изворни кода

plugins/sslutils.c - null terminate, fix buffer

Coverity 66527 - when writing to cn, we should pass sizeof()-1 as internal openssl logic does not account for starting at 0 and could overflow the buffer. It would only be by 1 byte though..
Spenser Reinhardt пре 11 година
родитељ
комит
0463f78c1d
1 измењених фајлова са 2 додато и 2 уклоњено
  1. 2 2
      plugins/sslutils.c

+ 2 - 2
plugins/sslutils.c

@@ -171,9 +171,9 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
 		printf("%s\n",_("CRITICAL - Cannot retrieve certificate subject."));
 		return STATE_CRITICAL;
 	}
-	cnlen = X509_NAME_get_text_by_NID(subj, NID_commonName, cn, sizeof(cn));
+	cnlen = X509_NAME_get_text_by_NID(subj, NID_commonName, cn, sizeof(cn)-1);
 	if (cnlen == -1)
-		strcpy(cn, _("Unknown CN"));
+		strncpy(cn, _("Unknown CN\0"), 12);
 
 	/* Retrieve timestamp of certificate */
 	tm = X509_get_notAfter(certificate);