Re: [Dovecot] possible bug in lib-mail source

2009-04-23 Thread Timo Sirainen
On Thu, 2009-04-23 at 10:29 +0200, Johann Klasek wrote:
> --- dovecot-1.2.rc3/src/lib-mail/message-header-parser.c.orig   2009-01-07 
> 19:33:26.0 +0100
> +++ dovecot-1.2.rc3/src/lib-mail/message-header-parser.c2009-04-23 
> 09:53:08.0 +0200
> @@ -284,7 +284,7 @@
>Exception to this is if the value consists only of
>LWSP, then skip only the one LWSP after ':'. */
> for (pos = 0; pos < line->value_len; pos++) {
> -   if (!IS_LWSP(line->value[0]))
> +   if (!IS_LWSP(line->value[pos]))
> break;
> }

Thanks, committed: http://hg.dovecot.org/dovecot-1.2/rev/c8de2237478f



signature.asc
Description: This is a digitally signed message part


[Dovecot] possible bug in lib-mail source

2009-04-23 Thread Johann Klasek

Browsing through the source code to find some properties of
deliver I stuck here:

--- dovecot-1.2.rc3/src/lib-mail/message-header-parser.c.orig   2009-01-07 
19:33:26.0 +0100
+++ dovecot-1.2.rc3/src/lib-mail/message-header-parser.c2009-04-23 
09:53:08.0 +0200
@@ -284,7 +284,7 @@
   Exception to this is if the value consists only of
   LWSP, then skip only the one LWSP after ':'. */
for (pos = 0; pos < line->value_len; pos++) {
-   if (!IS_LWSP(line->value[0]))
+   if (!IS_LWSP(line->value[pos]))
break;
}


I'm not clear if this was really indented but the for-loop does not use
the variable pos in the loop body. The expression
!IS_LWSP(line->value[0]) is invariant and always false if the first
character after ':' is a white space, forcing the loop to go through the
whole value.

This happens only if flag MESSAGE_HEADER_PARSER_FLAG_SKIP_INITIAL_LWSP
is active.

I saw this in 1.1.4 too.

Johann Klasek

-- 
Johann E. Klasek  Zentraler Informatikdienst - Kommunikation
Technische Universität Wien   Tel: +43 1 58801-42049
A-1040 Wien, Wiedner Hauptstr. 8-10/020C  Fax: +43 1 58801-42099
http://pgpkeys.tuwien.ac.at/   PGP  Key  jklasek