From: Howard Chu Date: Mon, 23 Nov 2020 17:14:00 +0000 (+0000) Subject: [PATCH] ITS#9404 fix serialNumberAndIssuerCheck X-Git-Tag: archive/raspbian/2.4.47+dfsg-3+rpi1+deb10u5^2~14 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ec35c800c7128046d51e5b6be5259521ad1e1f6a;p=openldap.git [PATCH] ITS#9404 fix serialNumberAndIssuerCheck Tighten validity checks Gbp-Pq: Name ITS-9404-fix-serialNumberAndIssuerCheck.patch --- diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index d6a54ad0..8e4b4bcc 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -3189,7 +3189,7 @@ serialNumberAndIssuerCheck( if( in->bv_len < 3 ) return LDAP_INVALID_SYNTAX; - if( in->bv_val[0] != '{' && in->bv_val[in->bv_len-1] != '}' ) { + if( in->bv_val[0] != '{' || in->bv_val[in->bv_len-1] != '}' ) { /* Parse old format */ is->bv_val = ber_bvchr( in, '$' ); if( BER_BVISNULL( is ) ) return LDAP_INVALID_SYNTAX; @@ -3220,7 +3220,7 @@ serialNumberAndIssuerCheck( HAVE_ALL = ( HAVE_ISSUER | HAVE_SN ) } have = HAVE_NONE; - int numdquotes = 0; + int numdquotes = 0, gotquote; struct berval x = *in; struct berval ni; x.bv_val++; @@ -3262,11 +3262,12 @@ serialNumberAndIssuerCheck( is->bv_val = x.bv_val; is->bv_len = 0; - for ( ; is->bv_len < x.bv_len; ) { + for ( gotquote=0; is->bv_len < x.bv_len; ) { if ( is->bv_val[is->bv_len] != '"' ) { is->bv_len++; continue; } + gotquote = 1; if ( is->bv_val[is->bv_len+1] == '"' ) { /* double dquote */ numdquotes++; @@ -3275,6 +3276,8 @@ serialNumberAndIssuerCheck( } break; } + if ( !gotquote ) return LDAP_INVALID_SYNTAX; + x.bv_val += is->bv_len + 1; x.bv_len -= is->bv_len + 1;