]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/url.c
Silence warning in print_deref(): cast lutil_b64_ntop() arg to unsigned char*
[openldap] / libraries / libldap / url.c
index 882d21da30c3919a6969eca9e8abe86a682b7829..f681a72533ac1fff1fe1be18a631be46ffbf5aa2 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2007 The OpenLDAP Foundation.
+ * Copyright 1998-2009 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -590,9 +590,11 @@ desc2str_len( LDAPURLDesc *u )
        }
 
        if ( u->lud_host && u->lud_host[0] ) {
+               char *ptr;
                len += hex_escape_len( u->lud_host, URLESC_SLASH );
-               if ( !is_ipc && strchr( u->lud_host, ':' )) {
-                       len += 2;       /* IPv6, [] */
+               if ( !is_ipc && ( ptr = strchr( u->lud_host, ':' ))) {
+                       if ( strchr( ptr+1, ':' ))
+                               len += 2;       /* IPv6, [] */
                }
        }
 
@@ -610,6 +612,7 @@ desc2str( LDAPURLDesc *u, char *s, int len )
        int             is_v6 = 0;
        int             is_ipc = 0;
        struct berval   scope = BER_BVNULL;
+       char            *ptr;
 
        if ( u == NULL ) {
                return -1;
@@ -637,19 +640,22 @@ desc2str( LDAPURLDesc *u, char *s, int len )
                sep = 1;
        }
 
-       if ( !is_ipc && u->lud_host && strchr( u->lud_host, ':' )) {
-               is_v6 = 1;
+       if ( !is_ipc && u->lud_host && ( ptr = strchr( u->lud_host, ':' ))) {
+               if ( strchr( ptr+1, ':' ))
+                       is_v6 = 1;
        }
 
        if ( u->lud_port ) {
-               len -= sprintf( s, "%s://%s%s%s:%d%n", u->lud_scheme,
+               sofar = sprintf( s, "%s://%s%s%s:%d", u->lud_scheme,
                                is_v6 ? "[" : "",
                                u->lud_host ? u->lud_host : "",
                                is_v6 ? "]" : "",
-                               u->lud_port, &sofar );
+                               u->lud_port );
+               len -= sofar;
 
        } else {
-               len -= sprintf( s, "%s://%n", u->lud_scheme, &sofar );
+               sofar = sprintf( s, "%s://", u->lud_scheme );
+               len -= sofar;
                if ( u->lud_host && u->lud_host[0] ) {
                        if ( is_v6 ) {
                                s[sofar++] = '[';