From 07dc23f5eeacc26a9a10aabece29a3938c2a79c4 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sun, 15 Nov 2009 18:26:53 +0000 Subject: [PATCH] treat bervals as bervals (related to ITS#6378,ITS#6379) --- include/lutil.h | 2 ++ servers/slapd/schema_init.c | 51 ++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/include/lutil.h b/include/lutil.h index cda43ebb23..fa05e2866d 100644 --- a/include/lutil.h +++ b/include/lutil.h @@ -194,6 +194,8 @@ lutil_strncopy LDAP_P(( char *dst, const char *src, size_t n )); LDAP_LUTIL_F( char* ) lutil_memcopy LDAP_P(( char *dst, const char *src, size_t n )); +#define lutil_strbvcopy(a, bv) lutil_memcopy((a),(bv)->bv_val,(bv)->bv_len) + struct tm; /* use this macro to statically allocate buffer for lutil_gentime */ diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 55fc2fa888..0e473744e5 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -2265,8 +2265,7 @@ postalAddressNormalize( p = normalized->bv_val; for ( l = 0; !BER_BVISNULL( &nlines[l] ); l++ ) { - p = lutil_memcopy( p, nlines[l].bv_val, nlines[l].bv_len ); - + p = lutil_strbvcopy( p, &nlines[l] ); *p++ = '$'; } *--p = '\0'; @@ -3329,9 +3328,9 @@ serialNumberAndIssuerPretty( p = out->bv_val; p = lutil_strcopy( p, "{ serialNumber " /*}*/ ); - p = lutil_strncopy( p, sn.bv_val, sn.bv_len ); + p = lutil_strbvcopy( p, &sn ); p = lutil_strcopy( p, ", issuer rdnSequence:\"" ); - p = lutil_strncopy( p, ni.bv_val, ni.bv_len ); + p = lutil_strbvcopy( p, &ni ); p = lutil_strcopy( p, /*{*/ "\" }" ); assert( p == &out->bv_val[out->bv_len] ); @@ -3491,9 +3490,9 @@ serialNumberAndIssuerNormalize( p = out->bv_val; p = lutil_strcopy( p, "{ serialNumber " /*}*/ ); - p = lutil_strncopy( p, sn3.bv_val, sn3.bv_len ); + p = lutil_strbvcopy( p, &sn3 ); p = lutil_strcopy( p, ", issuer rdnSequence:\"" ); - p = lutil_strncopy( p, ni.bv_val, ni.bv_len ); + p = lutil_strbvcopy( p, &ni ); p = lutil_strcopy( p, /*{*/ "\" }" ); assert( p == &out->bv_val[out->bv_len] ); @@ -3588,9 +3587,9 @@ certificateExactNormalize( p = normalized->bv_val; p = lutil_strcopy( p, "{ serialNumber " /*}*/ ); - p = lutil_strncopy( p, sn2.bv_val, sn2.bv_len ); + p = lutil_strbvcopy( p, &sn2 ); p = lutil_strcopy( p, ", issuer rdnSequence:\"" ); - p = lutil_strncopy( p, issuer_dn.bv_val, issuer_dn.bv_len ); + p = lutil_strbvcopy( p, &issuer_dn ); p = lutil_strcopy( p, /*{*/ "\" }" ); rc = LDAP_SUCCESS; @@ -3920,9 +3919,9 @@ issuerAndThisUpdatePretty( p = out->bv_val; p = lutil_strcopy( p, "{ issuer rdnSequence:\"" /*}*/ ); - p = lutil_strncopy( p, ni.bv_val, ni.bv_len ); + p = lutil_strbvcopy( p, &ni ); p = lutil_strcopy( p, "\", thisUpdate \"" ); - p = lutil_strncopy( p, tu.bv_val, tu.bv_len ); + p = lutil_strbvcopy( p, &tu ); p = lutil_strcopy( p, /*{*/ "\" }" ); assert( p == &out->bv_val[out->bv_len] ); @@ -3986,9 +3985,9 @@ issuerAndThisUpdateNormalize( p = out->bv_val; p = lutil_strcopy( p, "{ issuer rdnSequence:\"" /*}*/ ); - p = lutil_strncopy( p, ni.bv_val, ni.bv_len ); + p = lutil_strbvcopy( p, &ni ); p = lutil_strcopy( p, "\", thisUpdate \"" ); - p = lutil_strncopy( p, tu2.bv_val, tu2.bv_len ); + p = lutil_strbvcopy( p, &tu2 ); p = lutil_strcopy( p, /*{*/ "\" }" ); assert( p == &out->bv_val[out->bv_len] ); @@ -4081,9 +4080,9 @@ certificateListExactNormalize( p = normalized->bv_val; p = lutil_strcopy( p, "{ issuer rdnSequence:\"" ); - p = lutil_strncopy( p, issuer_dn.bv_val, issuer_dn.bv_len ); + p = lutil_strbvcopy( p, &issuer_dn ); p = lutil_strcopy( p, "\", thisUpdate \"" ); - p = lutil_strncopy( p, thisUpdate.bv_val, thisUpdate.bv_len ); + p = lutil_strbvcopy( p, &thisUpdate ); p = lutil_strcopy( p, /*{*/ "\" }" ); rc = LDAP_SUCCESS; @@ -4516,11 +4515,11 @@ serialNumberAndIssuerSerialPretty( p = out->bv_val; p = lutil_strcopy( p, "{ serialNumber " ); - p = lutil_strncopy( p, sn.bv_val, sn.bv_len ); + p = lutil_strbvcopy( p, &sn ); p = lutil_strcopy( p, ", issuer { baseCertificateID { issuer { directoryName:rdnSequence:\"" ); - p = lutil_strncopy( p, ni.bv_val, ni.bv_len ); + p = lutil_strbvcopy( p, &ni ); p = lutil_strcopy( p, "\" }, serial " ); - p = lutil_strncopy( p, i_sn.bv_val, i_sn.bv_len ); + p = lutil_strbvcopy( p, &i_sn ); p = lutil_strcopy( p, " } } }" ); assert( p == &out->bv_val[out->bv_len] ); @@ -4630,11 +4629,11 @@ serialNumberAndIssuerSerialNormalize( p = out->bv_val; p = lutil_strcopy( p, "{ serialNumber " ); - p = lutil_strncopy( p, sn3.bv_val, sn3.bv_len ); + p = lutil_strbvcopy( p, &sn3 ); p = lutil_strcopy( p, ", issuer { baseCertificateID { issuer { directoryName:rdnSequence:\"" ); - p = lutil_strncopy( p, ni.bv_val, ni.bv_len ); + p = lutil_strbvcopy( p, &ni ); p = lutil_strcopy( p, "\" }, serial " ); - p = lutil_strncopy( p, i_sn3.bv_val, i_sn3.bv_len ); + p = lutil_strbvcopy( p, &i_sn3 ); p = lutil_strcopy( p, " } } }" ); assert( p == &out->bv_val[out->bv_len] ); @@ -4763,11 +4762,11 @@ attributeCertificateExactNormalize( p = normalized->bv_val; p = lutil_strcopy( p, "{ serialNumber " ); - p = lutil_strncopy( p, sn2.bv_val, sn2.bv_len ); + p = lutil_strbvcopy( p, &sn2 ); p = lutil_strcopy( p, ", issuer { baseCertificateID { issuer { directoryName:rdnSequence:\"" ); - p = lutil_strncopy( p, issuer_dn.bv_val, issuer_dn.bv_len ); + p = lutil_strbvcopy( p, &issuer_dn ); p = lutil_strcopy( p, "\" }, serial " ); - p = lutil_strncopy( p, i_sn2.bv_val, i_sn2.bv_len ); + p = lutil_strbvcopy( p, &i_sn2 ); p = lutil_strcopy( p, " } } }" ); Debug( LDAP_DEBUG_TRACE, "attributeCertificateExactNormalize: %s\n", @@ -5108,7 +5107,7 @@ csnNormalize21( ptr = lutil_strncopy( ptr, >.bv_val[ STRLENOF( "YYYYmmddHH:MM:" ) ], STRLENOF( "SS" ) ); ptr = lutil_strcopy( ptr, ".000000Z#00" ); - ptr = lutil_strncopy( ptr, cnt.bv_val, cnt.bv_len ); + ptr = lutil_strbvcopy( ptr, &cnt ); *ptr++ = '#'; *ptr++ = '0'; *ptr++ = '0'; @@ -5201,7 +5200,7 @@ csnNormalize23( ptr = bv.bv_val; ptr = lutil_strncopy( ptr, gt.bv_val, gt.bv_len - 1 ); ptr = lutil_strcopy( ptr, ".000000Z#" ); - ptr = lutil_strncopy( ptr, cnt.bv_val, cnt.bv_len ); + ptr = lutil_strbvcopy( ptr, &cnt ); *ptr++ = '#'; *ptr++ = '0'; for ( i = 0; i < sid.bv_len; i++ ) { @@ -5556,7 +5555,7 @@ generalizedTimeValidate( return check_time_syntax(in, 0, parts, &fraction); } -static int +int generalizedTimeNormalize( slap_mask_t usage, Syntax *syntax, -- 2.39.5