From: Ondřej Kuzník Date: Thu, 3 Oct 2024 11:39:52 +0000 (+0100) Subject: ITS#10263 Reject modifications with invalid whitespace X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=40b6592adf0a638c7a5560d630640580e60004e7;p=thirdparty%2Fopenldap.git ITS#10263 Reject modifications with invalid whitespace --- diff --git a/libraries/libldap/ldifutil.c b/libraries/libldap/ldifutil.c index 24227eb77d..370d951f88 100644 --- a/libraries/libldap/ldifutil.c +++ b/libraries/libldap/ldifutil.c @@ -239,8 +239,6 @@ short_input: /* Check for changetype */ if ( BV_CASEMATCH( lr->lr_btype+i, &BV_CHANGETYPE )) { -#ifdef LIBERAL_CHANGETYPE_MODOP - /* trim trailing spaces (and log warning ...) */ int icnt; for ( icnt = lr->lr_vals[i].bv_len; --icnt > 0; ) { if ( !isspace( (unsigned char) lr->lr_vals[i].bv_val[icnt] ) ) { @@ -249,12 +247,21 @@ short_input: } if ( ++icnt != lr->lr_vals[i].bv_len ) { +#ifdef LIBERAL_CHANGETYPE_MODOP + /* trim trailing spaces (and log warning ...) */ fprintf( stderr, _("%s: illegal trailing space after" " \"%s: %s\" trimmed (line %lu, entry \"%s\")\n"), errstr, BV_CHANGETYPE.bv_val, lr->lr_vals[i].bv_val, linenum+i, dn ); lr->lr_vals[i].bv_val[icnt] = '\0'; + lr->lr_vals[i].bv_len = icnt; +#else /* !LIBERAL_CHANGETYPE_MODOP */ + fprintf( stderr, _("%s: illegal trailing space after" + " \"%s: %s\" (line %lu, entry \"%s\")\n"), + errstr, BV_CHANGETYPE.bv_val, lr->lr_vals[i].bv_val, linenum+i, dn ); + rc = LDAP_PARAM_ERROR; + goto leave; +#endif /* !LIBERAL_CHANGETYPE_MODOP */ } -#endif /* LIBERAL_CHANGETYPE_MODOP */ /* if LDIF_ENTRIES_ONLY, then either the changetype must be add, or there must be no changetype, and the flag LDIF_DEFAULT_ADD must be set */ @@ -442,7 +449,6 @@ short_input: for ( ; ilr_lines; i++ ) { if ( expect_modop ) { -#ifdef LIBERAL_CHANGETYPE_MODOP /* trim trailing spaces (and log warning ...) */ int icnt; for ( icnt = lr->lr_vals[i].bv_len; --icnt > 0; ) { @@ -450,12 +456,22 @@ short_input: } if ( ++icnt != lr->lr_vals[i].bv_len ) { +#ifdef LIBERAL_CHANGETYPE_MODOP fprintf( stderr, _("%s: illegal trailing space after" " \"%s: %s\" trimmed (line %lu, entry \"%s\")\n"), - errstr, type, lr->lr_vals[i].bv_val, linenum+i, dn ); + errstr, lr->lr_btype[i].bv_val, lr->lr_vals[i].bv_val, + linenum+i, dn ); lr->lr_vals[i].bv_val[icnt] = '\0'; + lr->lr_vals[i].bv_len = icnt; +#else /* !LIBERAL_CHANGETYPE_MODOP */ + fprintf( stderr, _("%s: illegal trailing space after" + " \"%s: %s\" (line %lu, entry \"%s\")\n"), + errstr, lr->lr_btype[i].bv_val, lr->lr_vals[i].bv_val, + linenum+i, dn ); + rc = LDAP_PARAM_ERROR; + goto leave; +#endif /* !LIBERAL_CHANGETYPE_MODOP */ } -#endif /* LIBERAL_CHANGETYPE_MODOP */ expect_modop = 0; expect_sep = 1;