[sync] Infinite loop in Horde/Icalendar.php when syncing

Carsten Schumann grypho at tempus-vivit.net
Tue Aug 23 13:11:32 UTC 2011


On Mon, 22 Aug 2011 17:43:36 +0200, Jan Schneider wrote:
> Zitat von Carsten Schumann <grypho at tempus-vivit.net>:
>
>> Hi guys,
>>
>> I have reinstalled my horde webmail since I had to upgrade from  
>> webmail 1.2.4 to 4.0.2 for my new Ipad. The web frontend works fine  
>> but when I try to sync my mobile phone against kronolith, apache  ends 
>> up in an infinite loop in Horde/Icalendar.php:584 while trying  to 
>> parse the answer from my phone.
>>
>> The loop reads:
>>
>>         while  
>> (preg_match_all('/^([^:]+;\s*(ENCODING=)?QUOTED-PRINTABLE(.*=\r?\n)+(.*[^=])?(\r?\n|$))/mU', 
>> $vCal, $matches))  {
>>             foreach ($matches[1] as $s) {
>>                 $r = preg_replace('/=\r?\n\s/', '', $s);
>>                 $vCal = str_replace($s, $r, $vCal);
>>             }
>>         }
>>
>>
>> $vCal has the value
>>
>> X-IRMC-LUID:3422981680^M CATEGORIES:Memo^M  
>> SUMMARY;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:Feuerwehr:=20Baumaktion=20Au=^M 
>> fr=C3=A4umen^M DTSTART:20071201T100000Z^M  DTEND:20071201T120000Z
>>
>> and after the preg_match_all instruction, $matches[1] contains an  
>> array with one element
>>
>> 
>> SUMMARY;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:Feuerwehr:=20Baumaktion=20Au=^M 
>>  fr=C3=A4umen^M
>>
>> which is not altered by the preg_replace expression. As $r==$s  
>> nothing is altered by str_replace expression in $vCal. So the  
>> preg_match_all matches again and again and again... ;-)
>>
>> Is this issue known and is there a bugfix/workaround?
>
> No. Is that a copy and paste error, or is the data really one single
> line? It's not valid iCalendar data then.
>
> Jan.
>
> --
> Do you need professional PHP or Horde consulting?
> http://horde.org/consulting/


Hi Jan,

you were right. The single line was produced by a "quick" hack to 
output the line which causes the infinite loop using log_error($vCal).

I've turned on sync logging now and in /tmp/client_11.wbxml I have 
found the corresponding lines:

[...]
@AAA`KC21 at AZ@ASCtext/x-vcalendar at AA@@TgWC3422981680 at AAOCBEGIN:VCALENDAR
VERSION:1.0
BEGIN:VEVENT
X-IRMC-LUID:3422981680
CATEGORIES:Memo
SUMMARY;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:Feuerwehr:=20Baumaktion=20Au=
fr=C3=A4umen
DTSTART:20071201T100000Z
DTEND:20071201T120000Z
END:VEVENT
END:VCALENDAR
[...]


/tmp/sync/data.txt reads:

[...]
Input received from client (text/x-vcalendar):
BEGIN:VCALENDARM
VERSION:1.0M
BEGIN:VEVENTM
X-IRMC-LUID:3422981680M
CATEGORIES:MemoM
SUMMARY;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:Feuerwehr:=20Baumaktion=20Au=M
fr=C3=A4umenM
DTSTART:20071201T100000ZM
DTEND:20071201T120000ZM
END:VEVENTM
END:VCALENDARM

[EOF]

/tmp/sync/log.txt does only mention client_10.wbxml. The file 
client_11.wbxml is not mentioned.

/tmp/sync/devinf.txt is quite large so i won't send it to the list. If 
it's required, just tell me and I will send it in a separate mail.

Carsten




More information about the sync mailing list