Blame SOURCES/0030-Issue-4884-server-crashes-when-dnaInterval-attribute.patch

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