]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/getdn.c
bug fixes for ldap_msgtype and ldap_msgid
[openldap] / libraries / libldap / getdn.c
index dfd1c2e28a7fd217488d5b2d9f70afa44e37f1a4..0110e298e719649340db1af1513c6c3e8072fc37 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -22,7 +23,7 @@
 
 #include "ldap-int.h"
 
-static char **explode_name( LDAP_CONST char *name, int notypes, int is_dn );
+static char **explode_name( const char *name, int notypes, int is_dn );
 
 char *
 ldap_get_dn( LDAP *ld, LDAPMessage *entry )
@@ -38,7 +39,7 @@ ldap_get_dn( LDAP *ld, LDAPMessage *entry )
        }
 
        tmp = *entry->lm_ber;   /* struct copy */
-       if ( ber_scanf( &tmp, "{a", &dn ) == LBER_ERROR ) {
+       if ( ber_scanf( &tmp, "{a" /*}*/, &dn ) == LBER_ERROR ) {
                ld->ld_errno = LDAP_DECODING_ERROR;
                return( NULL );
        }
@@ -54,8 +55,16 @@ ldap_dn2ufn( LDAP_CONST char *dn )
 
        Debug( LDAP_DEBUG_TRACE, "ldap_dn2ufn\n", 0, 0, 0 );
 
-       if ( ldap_is_dns_dn( dn ) || ( p = strchr( dn, '=' )) == NULL )
+       if( dn == NULL ) {
+               return NULL;
+       }
+
+       if ( ldap_is_dns_dn( dn ) ||
+               ( p = strchr( dn, '=' ) ) == NULL )
+       {
                return( LDAP_STRDUP( dn ) );
+       }
+
 
        ufn = LDAP_STRDUP( ++p );
 
@@ -182,7 +191,7 @@ ldap_explode_rdn( LDAP_CONST char *rdn, int notypes )
 }
 
 static char **
-explode_name( LDAP_CONST char *name, int notypes, int is_dn )
+explode_name( const char *name, int notypes, int is_dn )
 {
        const char *p, *q;
        char **parts = NULL;
@@ -279,7 +288,9 @@ explode_name( LDAP_CONST char *name, int notypes, int is_dn )
 int
 ldap_is_dns_dn( LDAP_CONST char *dn )
 {
-       return( dn[ 0 ] != '\0' && strchr( dn, '=' ) == NULL &&
-           strchr( dn, ',' ) == NULL );
+       return( dn[ 0 ] != '\0'
+               && strchr( dn, '=' ) == NULL
+               && strchr( dn, ',' ) == NULL
+               && strchr( dn, ';' ) == NULL );
 }