]> git.sur5r.net Git - openldap/commitdiff
improve parsing - first step
authorPierangelo Masarati <ando@openldap.org>
Fri, 18 Jun 2004 08:36:30 +0000 (08:36 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 18 Jun 2004 08:36:30 +0000 (08:36 +0000)
libraries/libldap/url.c

index 640218c7dc0b4bdcd7237791a6002c30835df05e..207c9d5fcba43852ee2f58f2233044595599ca00 100644 (file)
@@ -554,6 +554,8 @@ ldap_url_parse_ext( LDAP_CONST char *url_in, LDAPURLDesc **ludpp )
        }
 
        if ( q != NULL ) {
+               char    *next;
+
                *q++ = '\0';
                ldap_pvt_hex_unescape( q );
 
@@ -563,7 +565,12 @@ ldap_url_parse_ext( LDAP_CONST char *url_in, LDAPURLDesc **ludpp )
                        return LDAP_URL_ERR_BADURL;
                }
 
-               ludp->lud_port = atoi( q );
+               ludp->lud_port = strtol( q, &next, 10 );
+               if ( next == NULL || next[0] != '\0' ) {
+                       LDAP_FREE( url );
+                       ldap_free_urldesc( ludp );
+                       return LDAP_URL_ERR_BADURL;
+               }
        }
 
        ldap_pvt_hex_unescape( url );
@@ -1003,9 +1010,14 @@ ldap_url_parsehosts(
                                }
                        }
                        if (p != NULL) {
+                               char    *next;
+
                                *p++ = 0;
                                ldap_pvt_hex_unescape(p);
-                               ludp->lud_port = atoi(p);
+                               ludp->lud_port = strtol( p, &next, 10 );
+                               if ( next == NULL || next[0] != '\0' ) {
+                                       return LDAP_PARAM_ERROR;
+                               }
                        }
                }
                ldap_pvt_hex_unescape(ludp->lud_host);