bugGNU Mailutils - Bugs: bug #45867, invalid processing of folded...

 
 

bug #45867: invalid processing of folded strings in mu_string_unfold in library v2.2

Submitted by:  Ivan Keberlein <ikeberlein>
Submitted on:  Thu 03 Sep 2015 03:39:25 AM UTC  
Votes:  1  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Invalid
Privacy: PublicAssigned to: Sergey Poznyakoff <gray>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 05 Sep 2015 07:27:22 PM UTC, comment #1:

mu_string_unfold is not expected to handle ASCII CR (\r) symbols. All Mailutils functions assume that lines in multiline text are terminated with a single LF (\n) character. The same applies to mu_string_unfold.

Your proposed modification will make the function work for your particular implementation, but will break its expected behaviour elsewhere. Besides, it assumes that \r is always followed by \n, which might not always be the case.

The CRLF->LF translation is built-in into the Mailutils transport level. If, for some reason, you need to process CRLF-terminated text, be sure
to translate it using the "CRLF" filter as shown in the example below (mailutils 2.99.x is assumed):

char *p
crlf_unfold (char *text)
{
mu_stream_t flt;
mu_stream_t input;
size_t len;
char *p = malloc (strlen (text)+1);

mu_static_memory_stream_create (&input, text, strlen (text));
mu_filter_create (&flt, input, "CRLF", MU_FILTER_DECODE, MU_STREAM_READ);
mu_stream_unref (input);
mu_stream_read (flt, p, sizeof (p), &len);
p[len] = 0;
int rc = mu_string_unfold (p, &len);
mu_stream_destroy (&flt);
if (rc)
{
free (p);
p = NULL;
}
return p;
}

For more info on CRLF filter, refer to http://mailutils.org/wiki/CRLF_%28filter%29

Sergey Poznyakoff <gray>
Project AdministratorIn charge of this item.
Thu 03 Sep 2015 03:39:25 AM UTC, original submission:

The function mu_string_unfold does not work as expected. In processed strings it leaves extra '\r' character.

For example, processing a string "this\r\n string\r\n was folded" the expected result should be "this string was folded", but actual result is "this\r string\r was folded".

Test to check function mu_string_unfold is attached. Patch to fix function mu_string_unfold is attached too.

Hope this helps.

Ivan Keberlein <ikeberlein>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #34800:  mu_string_unfold_test.c added by ikeberlein (638B - application/octet-stream)
file #34801:  fix_mu_string_unfold.patch added by ikeberlein (626B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by gray (Posted a comment)
  • -unavailable- added by ikeberlein (Voted in favor of this item)
  • -unavailable- added by ikeberlein (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 1 encouragement so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 25 Jul 2017 02:58:03 PM UTCgrayOpen/ClosedOpen=>Closed
    Sat 05 Sep 2015 07:27:22 PM UTCgrayStatusNone=>Invalid
      Assigned toNone=>gray
    Thu 03 Sep 2015 03:40:51 AM UTCikeberleinCarbon-Copy-=>Added ikeberlein
    Thu 03 Sep 2015 03:39:25 AM UTCikeberleinAttached File-=>Added mu_string_unfold_test.c, #34800
      Attached File-=>Added fix_mu_string_unfold.patch, #34801

    Back to the top


    Powered by Savane 3.1-cleanup1