andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone

Blame SOURCES/0015-Ticket-49408-Server-allows-to-set-any-nsds5replicaid.patch

081b2d
From 4569da8f2c55d54a34f31312ee5756c70a7f463c Mon Sep 17 00:00:00 2001
081b2d
From: Mark Reynolds <mreynolds@redhat.com>
081b2d
Date: Thu, 19 Oct 2017 17:33:10 -0400
081b2d
Subject: [PATCH] Ticket 49408 - Server allows to set any nsds5replicaid in the
081b2d
 existing replica entry
081b2d
081b2d
Description:  There was no value validation for replica ID.  Now there is.
081b2d
081b2d
https://pagure.io/389-ds-base/issue/49408
081b2d
081b2d
Reviewed by: tbordaz(Thanks!)
081b2d
081b2d
(cherry picked from commit 296f0abb78b7ec82580d039d9c505506f6ce07be)
081b2d
---
081b2d
 ldap/servers/plugins/replication/repl5_replica_config.c | 12 ++++++++++++
081b2d
 1 file changed, 12 insertions(+)
081b2d
081b2d
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
081b2d
index 22d766143..7477a292c 100644
081b2d
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
081b2d
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
081b2d
@@ -411,6 +411,18 @@ replica_config_modify(Slapi_PBlock *pb,
081b2d
                     slapi_ch_free_string(&new_repl_type);
081b2d
                     new_repl_type = slapi_ch_strdup(config_attr_value);
081b2d
                 } else if (strcasecmp(config_attr, attr_replicaId) == 0) {
081b2d
+                    char *endp = NULL;
081b2d
+                    int64_t rid = 0;
081b2d
+                    errno = 0;
081b2d
+                    rid = strtoll(config_attr_value, &endp, 10);
081b2d
+                    if (*endp != '\0' || rid > 65535 || rid < 1 || errno == ERANGE) {
081b2d
+                        *returncode = LDAP_UNWILLING_TO_PERFORM;
081b2d
+                        PR_snprintf(errortext, SLAPI_DSE_RETURNTEXT_SIZE,
081b2d
+                            "Attribute %s value (%s) is invalid, must be a number between 1 and 65535.\n",
081b2d
+                            config_attr, config_attr_value);
081b2d
+                        slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "replica_config_modify - %s\n", errortext);
081b2d
+                        break;
081b2d
+                    }
081b2d
                     slapi_ch_free_string(&new_repl_id);
081b2d
                     new_repl_id = slapi_ch_strdup(config_attr_value);
081b2d
                 } else if (strcasecmp(config_attr, attr_flags) == 0) {
081b2d
-- 
081b2d
2.13.6
081b2d