zrhoffman / rpms / 389-ds-base

Forked from rpms/389-ds-base 3 years ago
Clone

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

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