[mythtv-commits] Ticket #4825: check readlink for errors

MythTV mythtv at cvs.mythtv.org
Mon Mar 3 23:08:04 UTC 2008


#4825: check readlink for errors
---------------------------------------------+------------------------------
 Reporter:  Erik Hovland <erik at hovland.org>  |        Owner:  nigel     
     Type:  defect                           |       Status:  assigned  
 Priority:  minor                            |    Milestone:  0.22      
Component:  mythtv                           |      Version:  0.21-fixes
 Severity:  low                              |   Resolution:            
  Mlocked:  0                                |  
---------------------------------------------+------------------------------
Changes (by nigel):

  * owner:  ijr => nigel
  * status:  new => assigned


Comment:

 I'm still looking at the logic in that method, but the patch will return
 from it without adding the device. I suspect the change should be just to
 ignore all errors. ''e.g.'':
 {{{
 % svn diff libs/libmyth/mediamonitor-unix.cpp
 Index: libs/libmyth/mediamonitor-unix.cpp
 ===================================================================
 --- libs/libmyth/mediamonitor-unix.cpp  (revision 16346)
 +++ libs/libmyth/mediamonitor-unix.cpp  (working copy)
 @@ -465,9 +465,11 @@
      struct fstab * mep = NULL;
      char lpath[PATH_MAX];

 -    // Resolve the simlink for the device.
 +    // Resolve the symlink for the device.
      int len = readlink(devicePath, lpath, PATH_MAX);
 -    if (len > 0 && len < PATH_MAX)
 +    if (len == -1)
 +        len = 0;
 +    if (len < PATH_MAX)
          lpath[len] = 0;

      // Attempt to open the file system descriptor entry.
 @@ -495,7 +497,7 @@

          // Check to see if this is the same as our passed in device.
          if ((strcmp(devicePath, mep->fs_spec) != 0) &&
 -             (len && (strcmp(lpath, mep->fs_spec) != 0)))
 +            (strncmp(lpath, mep->fs_spec, PATH_MAX) != 0))
              continue;
      }

 }}}

-- 
Ticket URL: <http://svn.mythtv.org/trac/ticket/4825#comment:2>
MythTV <http://svn.mythtv.org/trac>
MythTV


More information about the mythtv-commits mailing list