Ticket #4825: libs_libmyth_mediamonitor-unix.cpp-check-readlink.patch

File libs_libmyth_mediamonitor-unix.cpp-check-readlink.patch, 853 bytes (added by Erik Hovland <erik@…>, 16 years ago)

adds a conditional to make really sure readlink worked properly

  • libs/libmyth/mediamonitor-unix.cpp

    Be carefull with readlink. It is a tricky libc call.
    
    From: Erik Hovland <erik@hovland.org>
    
    
    ---
    
     libs/libmyth/mediamonitor-unix.cpp |    3 +++
     1 files changed, 3 insertions(+), 0 deletions(-)
    
    diff --git a/libs/libmyth/mediamonitor-unix.cpp b/libs/libmyth/mediamonitor-unix.cpp
    index 3bc43ca..75ce967 100644
    a b  
    22
    33// Standard C headers
    44#include <cstdio>
     5#include <errno.h>
    56
    67// POSIX headers
    78#include <dirent.h>
    bool MediaMonitorUnix::AddDevice(const char* devPath) 
    469470    int len = readlink(devicePath, lpath, PATH_MAX);
    470471    if (len > 0 && len < PATH_MAX)
    471472        lpath[len] = 0;
     473    else if (len == -1 && errno != EINVAL)
     474        return false;
    472475
    473476    // Attempt to open the file system descriptor entry.
    474477    if (!setfsent())