mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-01-10 08:53:27 -05:00
Patch: Escape character troubles (ITS#1753)
================ Written by Hallvard B. Furuseth and placed into the public domain. This software is not subject to any license of the University of Oslo. ================ maildap could address buf[-1] if len was < 2. REWRITE_SUBMATCH_ESCAPE is '%', not '\'. librewrite and saslautz could walk past the end of a string which ended with an escape character. Hallvard B. Furuseth <h.b.furuseth@usit.uio.no>, April 2002.
This commit is contained in:
parent
fc71d62b92
commit
02e8527248
5 changed files with 8 additions and 7 deletions
|
|
@ -439,7 +439,7 @@ get_config_line( FILE *cf, int *lineno)
|
|||
continue;
|
||||
if ( strspn( buf, " \t\n" ) == len )
|
||||
continue;
|
||||
if ( buf[len-2] == '\\' ) {
|
||||
if ( len >= 2 && buf[len-2] == '\\' ) {
|
||||
pos = len - 2;
|
||||
room = sizeof(buf) - pos;
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -245,19 +245,20 @@ rewrite_map_parse(
|
|||
for ( p = string, cnt = 1; p[ 0 ] != '\0' && cnt > 0; p++ ) {
|
||||
if ( p[ 0 ] == REWRITE_SUBMATCH_ESCAPE ) {
|
||||
/*
|
||||
* '\' marks the beginning of a new map
|
||||
* '%' marks the beginning of a new map
|
||||
*/
|
||||
if ( p[ 1 ] == '{' ) {
|
||||
cnt++;
|
||||
/*
|
||||
* '\' followed by a digit may mark the beginning
|
||||
* '%' followed by a digit may mark the beginning
|
||||
* of an old map
|
||||
*/
|
||||
} else if ( isdigit( (unsigned char) p[ 1 ] ) && p[ 2 ] == '{' ) {
|
||||
cnt++;
|
||||
p++;
|
||||
}
|
||||
p++;
|
||||
if ( p[ 1 ] != '\0' )
|
||||
p++;
|
||||
} else if ( p[ 0 ] == '}' ) {
|
||||
cnt--;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ parse_line(
|
|||
}
|
||||
|
||||
for ( begin = p; p[ 0 ] != '\0'; p++ ) {
|
||||
if ( p[ 0 ] == '\\' ) {
|
||||
if ( p[ 0 ] == '\\' && p[ 1 ] != '\0' ) {
|
||||
p++;
|
||||
} else if ( p[ 0 ] == '\'' || p[ 0 ] == '\"') {
|
||||
if ( in_quoted_field && p[ 0 ] == quote ) {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ rewrite_subst_compile(
|
|||
for ( p = begin = result, subs_len = 0; p[ 0 ] != '\0'; p++ ) {
|
||||
|
||||
/*
|
||||
* Keep only single escapes '\'
|
||||
* Keep only single escapes '%'
|
||||
*/
|
||||
if ( p[ 0 ] != REWRITE_SUBMATCH_ESCAPE ) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ int slap_sasl_regexp_config( const char *match, const char *replace )
|
|||
reg->sr_offset[0] = -2;
|
||||
n = 1;
|
||||
for ( c = reg->sr_replace; *c; c++ ) {
|
||||
if ( *c == '\\' ) {
|
||||
if ( *c == '\\' && c[1] ) {
|
||||
c++;
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue