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

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