From 799f2b1449230111b2796fad39ae77a8db9c7f5e Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sun, 8 Oct 2006 17:14:04 +0000 Subject: [PATCH] I hate code duplication, but don't require functions from liblutil in libldap.so --- libraries/libldap/init.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/libraries/libldap/init.c b/libraries/libldap/init.c index c8a15f157b..3e0b2b2b06 100644 --- a/libraries/libldap/init.c +++ b/libraries/libldap/init.c @@ -210,10 +210,15 @@ static void openldap_ldap_init_w_conf( break; - case ATTR_INT: + case ATTR_INT: { + char *next; + long l; p = &((char *) gopts)[attrs[i].offset]; - (void)lutil_atoi( (int*) p, opt ); - break; + l = strtol( opt, &next, 10 ); + if ( next != opt && next[ 0 ] == '\0' ) { + * (int*) p = l; + } + } break; case ATTR_KV: { const struct ol_keyvalue *kv; @@ -250,18 +255,21 @@ static void openldap_ldap_init_w_conf( break; case ATTR_OPT_TV: { struct timeval tv; + char *next; tv.tv_sec = -1; tv.tv_usec = 0; - (void)lutil_atol( &tv.tv_sec, opt ); - if ( tv.tv_sec > 0 ) { - (void)ldap_set_option( NULL, attrs[i].offset, (const void *)&tv); + tv.tv_sec = strtol( opt, &next, 10 ); + if ( next != opt && next[ 0 ] == '\0' && tv.tv_sec > 0 ) { + (void)ldap_set_option( NULL, attrs[i].offset, (const void *)&tv ); } } break; case ATTR_OPT_INT: { - int v = -1; - (void)lutil_atoi( &v, opt ); - if ( v > 0 ) { - (void)ldap_set_option( NULL, attrs[i].offset, (const void *)&v); + long l; + char *next; + l = strtol( opt, &next, 10 ); + if ( next != opt && next[ 0 ] == '\0' && l > 0 && (long)((int)l) == l ) { + int v = (int)l; + (void)ldap_set_option( NULL, attrs[i].offset, (const void *)&v ); } } break; } -- 2.39.5