/* line64.c - routines for dealing with the slapd line format */
/* $OpenLDAP$ */
/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
return -1;
}
- if( *p != *LDAP_DIRSEP ) {
+ /* we don't check for LDAP_DIRSEP since URLs should contain '/' */
+ if( *p != '/' ) {
/* skip over false root */
p++;
}
total = 0;
while( (bytes = fread( buffer, 1, sizeof(buffer), url )) != 0 ) {
- char *newp = ber_memrealloc( p, total + bytes );
+ char *newp = ber_memrealloc( p, total + bytes + 1 );
if( newp == NULL ) {
ber_memfree( p );
fclose( url );
return -1;
}
p = newp;
- SAFEMEMCPY( &p[total], buffer, bytes );
+ AC_MEMCPY( &p[total], buffer, bytes );
total += bytes;
}
fclose( url );
+ if( total == 0 ) {
+ char *newp = ber_memrealloc( p, 1 );
+ if( newp == NULL ) {
+ ber_memfree( p );
+ return -1;
+ }
+ p = newp;
+ }
+
+ p[total] = '\0';
*valuep = p;
*vlenp = total;