From: Kevin McCarthy Date: Sun, 13 Mar 2016 18:19:47 +0000 (-0700) Subject: Fix RFC2231 continuation join order. (closes #3811) (closes #3741) X-Git-Tag: neomutt-20160404~58 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=39453ca8bfae3c0059dbcb1ff18f933d553c78c6;p=neomutt Fix RFC2231 continuation join order. (closes #3811) (closes #3741) The function generating a list of parts to join had incorrect sorting logic. It was comparing values, not attributes. Additionally, the order logic wasn't correct. Thanks to TAKAHASHI Tamotsu for pointing out the value vs attribute comparison bug. --- diff --git a/rfc2231.c b/rfc2231.c index 98eddb39f..3a3a8fddd 100644 --- a/rfc2231.c +++ b/rfc2231.c @@ -239,19 +239,19 @@ static void rfc2231_list_insert (struct rfc2231_parameter **list, struct rfc2231_parameter *par) { struct rfc2231_parameter **last = list; - struct rfc2231_parameter *p = *list, *q; + struct rfc2231_parameter *p = *list; int c; - + while (p) { - last = &p->next; - q = p; p = p->next; - - c = strcmp (par->value, q->value); - if ((c > 0) || (c == 0 && par->index >= q->index)) + c = strcmp (par->attribute, p->attribute); + if ((c < 0) || (c == 0 && par->index <= p->index)) break; + + last = &p->next; + p = p->next; } - + par->next = p; *last = par; }