ber_strdup LDAP_P((
LDAP_CONST char * ));
+LBER_F( ber_len_t )
+ber_strnlen LDAP_P((
+ LDAP_CONST char *s, ber_len_t len ));
+
+LBER_F( char * )
+ber_strndup LDAP_P((
+ LDAP_CONST char *s, ber_len_t l ));
+
LBER_F( struct berval * )
ber_bvreplace LDAP_P((
struct berval *dst, LDAP_CONST struct berval *src ));
return ber_strdup_x( s, NULL );
}
+ber_len_t
+ber_strnlen( LDAP_CONST char *s, ber_len_t len )
+{
+#ifdef HAVE_STRNLEN
+ return (ber_len_t)strnlen( s, (ber_len_t)len );
+#else
+ ber_len_t l;
+
+ for ( l = 0; l < len; l++ ) {
+ if ( s[l] == '\0' ) {
+ return l;
+ }
+ }
+
+ return len;
+#endif /* HAVE_STRNLEN */
+}
+
char *
ber_strndup_x( LDAP_CONST char *s, ber_len_t l, void *ctx )
{
return NULL;
}
- len = strlen( s );
-
- if ( len > l ) {
- len = l;
- }
+ len = ber_strnlen( s, l );
if ( (p = ber_memalloc_x( len + 1, ctx )) == NULL ) {
ber_errno = LBER_ERROR_MEMORY;