Hi

Omar notized a bug around my code and asked me to fix this too.

[2024-01-27 18:33] Philipp <phil...@bureaucracy.de>
> @@ -420,14 +423,14 @@ ldap_run_query(int type, const char *key, char *dst, 
> size_t sz)
>               return -1;
>       }
>  
> -     if (snprintf(filter, sizeof(filter), q->filter, key)
> +     if (snprintf(filter, sizeof(filter), "%s", q->filter)
>           >= (int)sizeof(filter)) {

At this point it is not checked if the filter is set at all. A patch
for this is attached.

Philipp
From 07763c827f219749d544a8d2bd8926451330a6ec Mon Sep 17 00:00:00 2001
From: Philipp Takacs <phil...@bureaucracy.de>
Date: Sat, 27 Jan 2024 23:47:24 +0100
Subject: [PATCH 2/2] table-ldap check if a filter is configured before try to
 query

---
 extras/tables/table-ldap/table_ldap.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/extras/tables/table-ldap/table_ldap.c b/extras/tables/table-ldap/table_ldap.c
index 2b7d2d3..29cc15a 100644
--- a/extras/tables/table-ldap/table_ldap.c
+++ b/extras/tables/table-ldap/table_ldap.c
@@ -481,6 +481,12 @@ ldap_run_query(int type, const char *key, char *dst, size_t sz)
 		return -1;
 	}
 
+	if (!q->filter) {
+		/* XXX get the string of the type */
+		log_warnx("warn: query %d without a filter configured", type);
+		return -1;
+	}
+
 	if (snprintf(filter, sizeof(filter), "%s", q->filter)
 	    >= (int)sizeof(filter)) {
 		log_warnx("warn: filter too large");
-- 
2.39.2

Reply via email to