From: Howard Chu Date: Sun, 2 Dec 2007 19:11:41 +0000 (+0000) Subject: Add memctx to lutil_str2bin() X-Git-Tag: OPENLDAP_REL_ENG_2_4_9~20^2~363 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=304520c113d3978bfb1ff401b6b1abe2272fd2c5;p=openldap Add memctx to lutil_str2bin() --- diff --git a/include/lutil.h b/include/lutil.h index 2400624159..6c0b2f1580 100644 --- a/include/lutil.h +++ b/include/lutil.h @@ -305,7 +305,7 @@ lutil_atoulx( unsigned long *v, const char *s, int x ); #define lutil_atoul(v, s) lutil_atoulx((v), (s), 10) LDAP_LUTIL_F (int) -lutil_str2bin( struct berval *in, struct berval *out ); +lutil_str2bin( struct berval *in, struct berval *out, void *ctx ); /* Parse and unparse time intervals */ LDAP_LUTIL_F (int) diff --git a/libraries/liblutil/utils.c b/libraries/liblutil/utils.c index f14e6c877d..62db930f44 100644 --- a/libraries/liblutil/utils.c +++ b/libraries/liblutil/utils.c @@ -35,6 +35,7 @@ #include "lutil.h" #include "ldap_defaults.h" #include "ldap_pvt.h" +#include "lber_pvt.h" #ifdef HAVE_EBCDIC int _trans_argv = 1; @@ -671,7 +672,7 @@ scale( int new, lutil_int_decnum *prev, unsigned char *tmp ) * any hex input. */ int -lutil_str2bin( struct berval *in, struct berval *out ) +lutil_str2bin( struct berval *in, struct berval *out, void *ctx ) { char *pin, *pout, ctmp; char *end; @@ -747,7 +748,7 @@ lutil_str2bin( struct berval *in, struct berval *out ) /* tmp must be at least as large as outbuf */ if ( out->bv_len > sizeof(tmpbuf)) { - tmp = ber_memalloc( out->bv_len ); + tmp = ber_memalloc_x( out->bv_len, ctx ); } else { tmp = tmpbuf; } @@ -795,7 +796,7 @@ lutil_str2bin( struct berval *in, struct berval *out ) out->bv_len = num.len; decfail: if ( tmp != tmpbuf ) { - ber_memfree( tmp ); + ber_memfree_x( tmp, ctx ); } } return rc; diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index f40d91f749..03c47918b8 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -2120,7 +2120,8 @@ static int integerVal2Key( struct berval val, struct berval *key, - struct berval itmp + struct berval itmp, + void *ctx ) { /* index format: @@ -2150,7 +2151,7 @@ integerVal2Key( } } - if ( lutil_str2bin( &val, &itmp )) { + if ( lutil_str2bin( &val, &itmp, ctx )) { return LDAP_INVALID_SYNTAX; } @@ -2238,7 +2239,7 @@ integerIndexer( else if ( itmp.bv_len > maxstrlen ) itmp.bv_len = maxstrlen; } - rc = integerVal2Key( values[i], &keys[i], itmp ); + rc = integerVal2Key( values[i], &keys[i], itmp, ctx ); if ( rc ) goto leave; } @@ -2284,7 +2285,7 @@ integerFilter( iv.bv_len = sizeof(ibuf); } - rc = integerVal2Key( *value, keys, iv ); + rc = integerVal2Key( *value, keys, iv, ctx ); if ( rc == 0 ) *keysp = keys; @@ -3141,7 +3142,7 @@ serialNumberAndIssuerNormalize( } sn2.bv_val = stmp; sn2.bv_len = sn.bv_len; - if ( lutil_str2bin( &sn, &sn2 )) { + if ( lutil_str2bin( &sn, &sn2, ctx )) { rc = LDAP_INVALID_SYNTAX; goto leave; }