Fix RFC2231 continuation join order. (closes #3811) (closes #3741)
authorKevin McCarthy <kevin@8t8.us>
Sun, 13 Mar 2016 18:19:47 +0000 (11:19 -0700)
committerKevin McCarthy <kevin@8t8.us>
Sun, 13 Mar 2016 18:19:47 +0000 (11:19 -0700)
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.

rfc2231.c

index 98eddb39fd39f3c497b5628f2f5b1e088854ffa7..3a3a8fddd141736d7bcb67da2e347e6eab280b36 100644 (file)
--- 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;
 }