andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
6d0b66
From df0ccce06259b9ef06d522e61da4e3ffcbbf5016 Mon Sep 17 00:00:00 2001
6d0b66
From: Mark Reynolds <mreynolds@redhat.com>
6d0b66
Date: Wed, 25 Aug 2021 16:54:57 -0400
6d0b66
Subject: [PATCH] Issue 4884 - server crashes when dnaInterval attribute is set
6d0b66
 to zero
6d0b66
6d0b66
Bug Description:
6d0b66
6d0b66
A division by zero crash occurs if the dnaInterval is set to zero
6d0b66
6d0b66
Fix Description:
6d0b66
6d0b66
Validate the config value of dnaInterval and adjust it to the
6d0b66
default/safe value of "1" if needed.
6d0b66
6d0b66
relates: https://github.com/389ds/389-ds-base/issues/4884
6d0b66
6d0b66
Reviewed by: tbordaz(Thanks!)
6d0b66
---
6d0b66
 ldap/servers/plugins/dna/dna.c | 7 +++++++
6d0b66
 1 file changed, 7 insertions(+)
6d0b66
6d0b66
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
6d0b66
index 928a3f54a..c983ebdd0 100644
6d0b66
--- a/ldap/servers/plugins/dna/dna.c
6d0b66
+++ b/ldap/servers/plugins/dna/dna.c
6d0b66
@@ -1025,7 +1025,14 @@ dna_parse_config_entry(Slapi_PBlock *pb, Slapi_Entry *e, int apply)
6d0b66
 
6d0b66
     value = slapi_entry_attr_get_charptr(e, DNA_INTERVAL);
6d0b66
     if (value) {
6d0b66
+        errno = 0;
6d0b66
         entry->interval = strtoull(value, 0, 0);
6d0b66
+        if (entry->interval == 0 || errno == ERANGE) {
6d0b66
+            slapi_log_err(SLAPI_LOG_WARNING, DNA_PLUGIN_SUBSYSTEM,
6d0b66
+                          "dna_parse_config_entry - Invalid value for dnaInterval (%s), "
6d0b66
+                          "Using default value of 1\n", value);
6d0b66
+            entry->interval = 1;
6d0b66
+        }
6d0b66
         slapi_ch_free_string(&value);
6d0b66
     }
6d0b66
 
6d0b66
-- 
6d0b66
2.31.1
6d0b66