[BusyBox 0001320]: Patch for "libbb/find_root_device.c" to solve possible of endless loop

bugs at busybox.net bugs at busybox.net
Fri Apr 20 09:12:38 UTC 2007


The following issue has been SUBMITTED. 
====================================================================== 
http://busybox.net/bugs/view.php?id=1320 
====================================================================== 
Reported By:                rockeychu
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   1320
Category:                   Documentation
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             04-20-2007 02:12 PDT
Last Modified:              04-20-2007 02:12 PDT
====================================================================== 
Summary:                    Patch for "libbb/find_root_device.c" to solve
possible of endless loop
Description: 
libbb/find_root_device.c REV 18435 introduced a potential bug, which could
cause 'df' hung, such as when '/dev/fd' is symlink of '/proc/self/fd'. 
Symbolic link device is very dangerous when dealing with /dev/ subdir (it
may point to itself), so just omit it.

Patch as following:

Index: libbb/find_root_device.c
===================================================================
--- libbb/find_root_device.c    (revision 18501)
+++ libbb/find_root_device.c    (working copy)
@@ -41,12 +41,14 @@

        while ((entry = readdir(dir)) != NULL) {
                safe_strncpy(ap->devpath + len, entry->d_name, rem);
-               if (stat(ap->devpath, &ap->st) != 0)
+               if (lstat(ap->devpath, &ap->st) != 0)
                        continue;
                if (S_ISBLK(ap->st.st_mode) && ap->st.st_rdev == ap->dev)
{
                        retpath = xstrdup(ap->devpath);
                        break;
                }
+               if (S_ISLNK(ap->st.st_mode))
+                       continue;
                if (S_ISDIR(ap->st.st_mode)) {
                        /* Do not recurse for '.' and '..' */
                        if (DOT_OR_DOTDOT(entry->d_name))

====================================================================== 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
04-20-07 02:12  rockeychu      New Issue                                    
04-20-07 02:12  rockeychu      Status                   new => assigned     
04-20-07 02:12  rockeychu      Assigned To               => BusyBox         
======================================================================




More information about the busybox-cvs mailing list