]> git.sur5r.net Git - openldap/commitdiff
Passes last test (empty value); also passes many of the invalid DN tests if liberal...
authorPierangelo Masarati <ando@openldap.org>
Mon, 7 Jan 2002 15:23:23 +0000 (15:23 +0000)
committerPierangelo Masarati <ando@openldap.org>
Mon, 7 Jan 2002 15:23:23 +0000 (15:23 +0000)
libraries/libldap/getdn.c

index 83d61a61703bac6f8a70ac78bdf7efd89f33b4eb..f13042c7d7a2034d28fcbeb0575e63965dd7cfac 100644 (file)
@@ -689,7 +689,20 @@ ldap_str2dn( const char *str, LDAPDN **dn, unsigned flags )
                tmpDN[nrdns++] = newRDN;
                newRDN = NULL;
 
+#if 0
+               /*
+                * prone to attacks?
+                */
                assert (nrdns < TMP_SLOTS);
+#else
+               /*
+                * make the static AVA array dynamically rescalable
+                */
+               if (nrdns >= TMP_SLOTS) {
+                       rc = LDAP_DECODING_ERROR;
+                       goto parsing_error;
+               }
+#endif
                                
                if ( p[ 0 ] == '\0' ) {
                        /* 
@@ -1037,7 +1050,12 @@ ldap_str2rdn( const char *str, LDAPRDN **rdn, const char **n, unsigned flags )
                         * here STRING means RFC 2253 string
                         * FIXME: what about DCE strings? 
                         */
-                       state = B4STRINGVALUE;
+                       if ( !p[ 0 ] ) {
+                               /* empty value */
+                               state = GOTAVA;
+                       } else {
+                               state = B4STRINGVALUE;
+                       }
                        break;
 
                case B4BINARYVALUE:
@@ -1101,12 +1119,16 @@ ldap_str2rdn( const char *str, LDAPRDN **rdn, const char **n, unsigned flags )
                                 */
                                ava = ldapava_new( &attrType, &attrValue, 
                                                attrValueEncoding );
+                               
                                if ( ava == NULL ) {
                                        rc = LDAP_NO_MEMORY;
                                        goto parsing_error;
                                }
                                tmpRDN[navas++] = ava;
 
+                               attrValue.bv_val = NULL;
+                               attrValue.bv_len = 0;
+
                                assert(navas < TMP_SLOTS);
                        }