The following commit has been merged in the master branch:
commit c922a8f681dc27135947ebdaff68fc3158614807
Author: Guillem Jover <guil...@debian.org>
Date:   Thu Sep 8 19:12:20 2011 +0200

    u-a: Do not try to readlink() a non-symlink
    
    Return early in case the path is not a symlink, there's no point in
    calling readlink() if we know it's going to fail.

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index b8654fa..03ceb6d 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -289,6 +289,12 @@ areadlink(const char *linkname)
        /* Allocate required memory to store the value of the symlink */
        if (lstat(linkname, &st))
                return NULL;
+
+       if (!S_ISLNK(st.st_mode)) {
+               errno = EINVAL;
+               return NULL;
+       }
+
        buf = xmalloc(st.st_size + 1);
 
        /* Read it and terminate the string properly */

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to