X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Fliblutil%2Ffetch.c;h=6535dd20b6ec6b4cb358ce8097779d5dcce4c04c;hb=f2a02b90edde2dbecb342f040603ffac72d99c36;hp=fe56e6180967c8fd4beef0848fcf90a1c8e6d91b;hpb=341ac2a06675cb32788c868cfdcc83f64356944c;p=openldap diff --git a/libraries/liblutil/fetch.c b/libraries/liblutil/fetch.c index fe56e61809..6535dd20b6 100644 --- a/libraries/liblutil/fetch.c +++ b/libraries/liblutil/fetch.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1999-2005 The OpenLDAP Foundation. + * Copyright 1999-2007 The OpenLDAP Foundation. * Portions Copyright 1999-2003 Kurt D. Zeilenga. * All rights reserved. * @@ -43,24 +43,23 @@ ldif_open_url( LDAP_CONST char *urlstr ) { FILE *url; - char *p = NULL; #ifdef HAVE_FETCH url = fetchGetURL( (char*) urlstr, "" ); #else - if( strncasecmp( "file://", urlstr, sizeof("file://")-1 ) == 0 ) { - p = strchr( &urlstr[sizeof("file://")-1], '/' ); - if( p == NULL ) { - return NULL; - } + if( strncasecmp( "file:", urlstr, sizeof("file:")-1 ) == 0 ) { + char *p; + urlstr += sizeof("file:")-1; /* we don't check for LDAP_DIRSEP since URLs should contain '/' */ - if( p[1] == '.' && ( p[2] == '/' || ( p[2] == '.' && p[3] == '/' ))) { - /* skip over false root */ - p++; + if ( urlstr[0] == '/' && urlstr[1] == '/' ) { + urlstr += 2; + /* path must be absolute if authority is present */ + if ( urlstr[0] != '/' ) + return NULL; } - p = ber_strdup( p ); + p = ber_strdup( urlstr ); ldap_pvt_hex_unescape( p ); url = fopen( p, "rb" );