The following commit has been merged in the sid branch:
commit 867edc4d1736e0052143d1cd28b7dda3fd71ba45
Author: Raphaël Hertzog <[email protected]>
Date:   Thu Jul 29 20:36:09 2010 +0200

    update-alternatives: fix off-by-one errors
    
    alternative_sort_choices() and alternative_sort_slaves() were affected
    by an off-by-one error that could result in linked lists looping over
    themselves since the last element was not properly put back in the list.

diff --git a/debian/changelog b/debian/changelog
index a291980..a5dbeac 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+dpkg (1.15.8.1) UNRELEASED; urgency=low
+
+  * Fix off-by-one error in update-alternatives that lead to an infinite loop
+    while writing the administrative file. Closes: #590854
+
+ -- Raphaël Hertzog <[email protected]>  Thu, 29 Jul 2010 20:32:33 +0200
+
 dpkg (1.15.8) unstable; urgency=low
 
   [ Raphaël Hertzog ]
diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 0f6487a..52148c3 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -772,10 +772,8 @@ alternative_sort_choices(struct alternative *a)
        /* Rewrite the linked list from the sorted table */
        a->choices = fs = table[0];
        table[count - 1]->next = NULL;
-       for (i = 1; i < count - 1; i++) {
+       for (i = 1; i < count; fs = fs->next, i++)
                fs->next = table[i];
-               fs = fs->next;
-       }
        free(table);
 }
 
@@ -800,7 +798,7 @@ alternative_sort_slaves(struct alternative *a)
        /* Rewrite the linked list from the sorted table */
        a->slaves = sl = table[0];
        table[count - 1]->next = NULL;
-       for (i = 1; i < count - 1; sl = sl->next, i++)
+       for (i = 1; i < count; sl = sl->next, i++)
                sl->next = table[i];
        free(table);
 }

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to