[389-devel] Please Review: (504817) Handle LDAPv2 quoted RDN values correctly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




>From 4c333c131975debacd65bdb5a96b7a56e9012048 Mon Sep 17 00:00:00 2001
From: Nathan Kinder <nkinder@xxxxxxxxxx>
Date: Wed, 11 Nov 2009 09:43:09 -0800
Subject: [PATCH] Bug 504817 - Handle LDAPv2 quoted RDN values correctly

The bug fix for bug 438139 introduced a regression that causes the
server to not handle LDAPv2 quoted RDN values correctly.  We were
including the '"' characters used to contain an unescaped value in
the actual value itself.

The proper thing to do is to eliminate any '"' characters that are
not escaped when we unescape the value.  I have tested this new fix
with the oringinal issue from bug 438139 to ensure that it does not
introduce a regression for that bug.
---
 ldap/servers/slapd/util.c |   54 +++++++++++++++++++++-----------------------
 1 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/ldap/servers/slapd/util.c b/ldap/servers/slapd/util.c
index 2f55ee4..c8d9a74 100644
--- a/ldap/servers/slapd/util.c
+++ b/ldap/servers/slapd/util.c
@@ -211,42 +211,40 @@ strcpy_unescape_value( char *d, const char *s )
     {
         switch ( *s )
         {
+        case '"':
+            break;
         case '\\':
-            if ( gotesc ) {
-                gotesc = 0;
-            } else {
-                gotesc = 1;
-                if ( s+2 < end ) {
-                    int n = hexchar2int( s[1] );
-                    /* If 8th bit is on, the char is not ASCII (not UTF-8).  
-                     * Thus, not UTF-8 */
-                    if ( n >= 0 && n < 8 ) {
-                        int n2 = hexchar2int( s[2] );
-                        if ( n2 >= 0 ) {
-                            n = (n << 4) + n2;
-                            if (n == 0) { /* don't change \00 */
-                                *d++ = *s++;
-                                *d++ = *s++;
-                                *d++ = *s;
-                            } else { /* change \xx to a single char */
-                                *d++ = (char)n;
-                                s += 2;
-                            }
-                            gotesc = 0;
+            gotesc = 1;
+            if ( s+2 < end ) {
+                int n = hexchar2int( s[1] );
+                /* If 8th bit is on, the char is not ASCII (not UTF-8).  
+                 * Thus, not UTF-8 */
+                if ( n >= 0 && n < 8 ) {
+                    int n2 = hexchar2int( s[2] );
+                    if ( n2 >= 0 ) {
+                        n = (n << 4) + n2;
+                        if (n == 0) { /* don't change \00 */
+                            *d++ = *s++;
+                            *d++ = *s++;
+                            *d++ = *s;
+                        } else { /* change \xx to a single char */
+                            *d++ = (char)n;
+                            s += 2;
                         }
+                        gotesc = 0;
                     }
                 }
-                if (gotesc) {
-                    *d++ = *s;
-                }
             }
-            break;
-        default:
+            /* This is an escaped single character (like \"), so
+             * just copy the special character and not the escape. */
             if (gotesc) {
-                d--;
+                s++;
+                *d++ = *s;
+                gotesc = 0;
             }
+            break;
+        default:
             *d++ = *s;
-            gotesc = 0;
             break;
         }
     }
-- 
1.6.2.5

--
389-devel mailing list
389-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-directory-devel

[Index of Archives]     [Fedora Directory Announce]     [Fedora Users]     [Older Fedora Users Mail]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Review]     [Fedora Art]     [Fedora Music]     [Fedora Packaging]     [CentOS]     [Fedora SELinux]     [Big List of Linux Books]     [KDE Users]     [Fedora Art]     [Fedora Docs]

  Powered by Linux