From 0eec70b9dbd0a50a24fe173a68fd9ab72857e08d Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Wed, 17 Feb 2021 13:40:52 -0500 Subject: [PATCH] Add NULL checks before string compares when analyzing a cert A user reported a segfault which was due to a broken request. How it got broken I have no idea but it was effectively empty. It had everything as defaults: 0, -1, UNSPECIFIED or not present at all. So when trying to analyze the request it did a NULL compare. https://pagure.io/certmonger/issue/191 --- src/tdbush.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tdbush.c b/src/tdbush.c index a10a1aff..fb81c477 100644 --- a/src/tdbush.c +++ b/src/tdbush.c @@ -678,14 +678,14 @@ base_add_request(DBusConnection *conn, DBusMessage *msg, if (cert_storage != e->cm_cert_storage_type) { continue; } - if (strcmp(cert_location, e->cm_cert_storage_location) != 0) { + if ((e->cm_cert_storage_location == NULL) || strcmp(cert_location, e->cm_cert_storage_location) != 0) { continue; } switch (cert_storage) { case cm_cert_storage_file: break; case cm_cert_storage_nssdb: - if (strcmp(cert_nickname, e->cm_cert_nickname) != 0) { + if ((e->cm_cert_nickname == NULL) || strcmp(cert_nickname, e->cm_cert_nickname) != 0) { continue; } break; -- 2.31.1