From 16d3ad01c0d460816bed2589d73c53c0d3b9820f Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Tue, 6 Oct 2009 22:03:15 +0000 Subject: [PATCH] don't "overflow" debug levels (ITS#6324) --- include/ldap_log.h | 2 +- servers/slapd/bconfig.c | 2 +- servers/slapd/main.c | 13 ++++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/ldap_log.h b/include/ldap_log.h index 9c1b2c7be3..a1e1f84dd0 100644 --- a/include/ldap_log.h +++ b/include/ldap_log.h @@ -123,7 +123,7 @@ LDAP_BEGIN_DECL #define LDAP_DEBUG_SYNC 0x4000 #define LDAP_DEBUG_NONE 0x8000 -#define LDAP_DEBUG_ANY -1 +#define LDAP_DEBUG_ANY ((unsigned long)-1) /* debugging stuff */ #ifdef LDAP_DEBUG diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index c03c23afda..ae51278ecf 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -3051,7 +3051,7 @@ static int loglevel_init( void ) { slap_verbmasks lo[] = { - { BER_BVC("Any"), -1 }, + { BER_BVC("Any"), LDAP_DEBUG_ANY }, { BER_BVC("Trace"), LDAP_DEBUG_TRACE }, { BER_BVC("Packets"), LDAP_DEBUG_PACKETS }, { BER_BVC("Args"), LDAP_DEBUG_ARGS }, diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 14fadd6b1a..2fc052369b 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -270,7 +270,18 @@ parse_debug_level( const char *arg, int *levelp, char ***unknowns ) ldap_charray_free( levels ); } else { - if ( lutil_atoix( &level, arg, 0 ) != 0 ) { + int rc; + + if ( arg[0] == '-' ) { + rc = lutil_atoix( &level, arg, 0 ); + } else { + unsigned ulevel; + + rc = lutil_atoux( &ulevel, arg, 0 ); + level = (int)ulevel; + } + + if ( rc ) { fprintf( stderr, "unrecognized log level " "\"%s\"\n", arg ); -- 2.39.5