From 942d37afc59f173df17412851bf52c4929535059 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 6 Dec 1999 06:33:26 +0000 Subject: [PATCH] Set ber_errno here and there. --- include/lber.h | 2 +- libraries/liblber/encode.c | 3 +-- libraries/liblber/memory.c | 5 ++++- libraries/liblber/options.c | 8 ++++++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/lber.h b/include/lber.h index c1d0d82a57..d85ec9f38b 100644 --- a/include/lber.h +++ b/include/lber.h @@ -64,7 +64,7 @@ LDAP_BEGIN_DECL * as valid BER tags, and so it is safe to use them to report errors. In * fact, any tag for which the following is true is invalid: */ -#define LBER_INVALID(t) (((t) & (ber_tag_t) 0x080) \ +#define LBER_INVALID(t) (((t) & (ber_tag_t) 0x080UL) \ && (((t) & (ber_tag_t) ~ 0x0FF)) #define LBER_ERROR ((ber_tag_t) -1) diff --git a/libraries/liblber/encode.c b/libraries/liblber/encode.c index 5f3ad7da4c..3003ddb330 100644 --- a/libraries/liblber/encode.c +++ b/libraries/liblber/encode.c @@ -299,8 +299,7 @@ ber_put_ostring( #ifdef STR_TRANSLATION if ( len > 0 && ( ber->ber_options & LBER_TRANSLATE_STRINGS ) != 0 && ber->ber_encode_translate_proc ) { - if ( (*(ber->ber_encode_translate_proc))( &str, &len, 0 ) - != 0 ) { + if ( (*(ber->ber_encode_translate_proc))( &str, &len, 0 ) != 0 ) { return( -1 ); } free_str = 1; diff --git a/libraries/liblber/memory.c b/libraries/liblber/memory.c index 604e8ccc94..5e1719ca68 100644 --- a/libraries/liblber/memory.c +++ b/libraries/liblber/memory.c @@ -83,7 +83,6 @@ ber_memfree( void *p ) assert( ber_int_memory_fns->bmf_free ); - (*ber_int_memory_fns->bmf_free)( p ); } @@ -268,10 +267,12 @@ ber_bvdup( ber_int_options.lbo_valid = LBER_INITIALIZED; if( bv == NULL ) { + ber_errno = LBER_ERROR_PARAM; return NULL; } if(( new = LBER_MALLOC( sizeof(struct berval) )) == NULL ) { + ber_errno = LBER_ERROR_MEMORY; return NULL; } @@ -282,6 +283,7 @@ ber_bvdup( } if(( new->bv_val = LBER_MALLOC( bv->bv_len + 1 )) == NULL ) { + ber_errno = LBER_ERROR_MEMORY; LBER_FREE( new ); return NULL; } @@ -312,6 +314,7 @@ ber_strdup( LDAP_CONST char *s ) len = strlen( s ) + 1; if ( (p = LBER_MALLOC( len )) == NULL ) { + ber_errno = LBER_ERROR_MEMORY; return( NULL ); } diff --git a/libraries/liblber/options.c b/libraries/liblber/options.c index 27a1de0ac0..811867810d 100644 --- a/libraries/liblber/options.c +++ b/libraries/liblber/options.c @@ -29,6 +29,7 @@ ber_get_option( if(outvalue == NULL) { /* no place to get to */ + ber_errno = LBER_ERROR_PARAM; return LBER_OPT_ERROR; } @@ -38,6 +39,7 @@ ber_get_option( return LBER_OPT_SUCCESS; } + ber_errno = LBER_ERROR_PARAM; return LBER_OPT_ERROR; } @@ -69,6 +71,7 @@ ber_get_option( default: /* bad param */ + ber_errno = LBER_ERROR_PARAM; break; } @@ -96,6 +99,7 @@ ber_set_option( if(!( f->bmf_malloc && f->bmf_calloc && f->bmf_realloc && f->bmf_free )) { + ber_errno = LBER_ERROR_PARAM; return LBER_OPT_ERROR; } @@ -103,6 +107,7 @@ ber_set_option( (*(f->bmf_malloc))(sizeof(BerMemoryFunctions)); if ( ber_int_memory_fns == NULL ) { + ber_errno = LBER_ERROR_MEMORY; return LBER_OPT_ERROR; } @@ -116,6 +121,7 @@ ber_set_option( if(invalue == NULL) { /* no place to set from */ + ber_errno = LBER_ERROR_PARAM; return LBER_OPT_ERROR; } @@ -129,6 +135,7 @@ ber_set_option( return LBER_OPT_SUCCESS; } + ber_errno = LBER_ERROR_PARAM; return LBER_OPT_ERROR; } @@ -160,6 +167,7 @@ ber_set_option( default: /* bad param */ + ber_errno = LBER_ERROR_PARAM; break; } -- 2.39.5