andykimpe / rpms / 389-ds-base

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

Blame SOURCES/0014-0002-Issue-4383-Do-not-normalize-escaped-spaces-in-a-DN.patch

0c1fc4
From 1675ffa44180b53e70381e6d10b09a5c4e438780 Mon Sep 17 00:00:00 2001
0c1fc4
From: Mark Reynolds <mreynolds@redhat.com>
0c1fc4
Date: Wed, 11 Nov 2020 08:59:18 -0500
0c1fc4
Subject: [PATCH 2/2] Issue 4383 - Do not normalize escaped spaces in a DN
0c1fc4
0c1fc4
Bug Description:  Adding an entry with an escaped leading space leads to many
0c1fc4
                  problems.  Mainly id2entry can get corrupted during an
0c1fc4
                  import of such an entry, and the entryrdn index is not
0c1fc4
                  updated correctly
0c1fc4
0c1fc4
Fix Description:  In slapi_dn_normalize_ext() leave an escaped space intact.
0c1fc4
0c1fc4
Relates: https://github.com/389ds/389-ds-base/issues/4383
0c1fc4
0c1fc4
Reviewed by: firstyear, progier, and tbordaz (Thanks!!!)
0c1fc4
---
0c1fc4
 ldap/servers/slapd/dn.c | 8 ++++++--
0c1fc4
 1 file changed, 6 insertions(+), 2 deletions(-)
0c1fc4
0c1fc4
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
0c1fc4
index 152561d33..965877850 100644
0c1fc4
--- a/ldap/servers/slapd/dn.c
0c1fc4
+++ b/ldap/servers/slapd/dn.c
0c1fc4
@@ -895,8 +895,7 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len)
0c1fc4
                             s++;
0c1fc4
                         }
0c1fc4
                     }
0c1fc4
-                } else if (s + 2 < ends &&
0c1fc4
-                           isxdigit(*(s + 1)) && isxdigit(*(s + 2))) {
0c1fc4
+                } else if (s + 2 < ends && isxdigit(*(s + 1)) && isxdigit(*(s + 2))) {
0c1fc4
                     /* esc hexpair ==> real character */
0c1fc4
                     int n = slapi_hexchar2int(*(s + 1));
0c1fc4
                     int n2 = slapi_hexchar2int(*(s + 2));
0c1fc4
@@ -904,6 +903,11 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len)
0c1fc4
                     if (n == 0) { /* don't change \00 */
0c1fc4
                         *d++ = *++s;
0c1fc4
                         *d++ = *++s;
0c1fc4
+                    } else if (n == 32) { /* leave \20 (space) intact */
0c1fc4
+                        *d++ = *s;
0c1fc4
+                        *d++ = *++s;
0c1fc4
+                        *d++ = *++s;
0c1fc4
+                        s++;
0c1fc4
                     } else {
0c1fc4
                         *d++ = n;
0c1fc4
                         s += 3;
0c1fc4
-- 
0c1fc4
2.26.2
0c1fc4