Ticket #5503: libs_libmythui-dont-pass-neg-to-dup.patch

File libs_libmythui-dont-pass-neg-to-dup.patch, 967 bytes (added by Erik Hovland <erik@…>, 11 years ago)

checks fd before calling dup

  • mythtv/libs/libmythui/mythsystem.cpp

    dup2 cannot take negative values.
    
    From: Erik Hovland <erik@hovland.org>
    
    
    ---
    
     mythtv/libs/libmythui/mythsystem.cpp |   11 +++++++++--
     1 files changed, 9 insertions(+), 2 deletions(-)
    
    diff --git a/mythtv/libs/libmythui/mythsystem.cpp b/mythtv/libs/libmythui/mythsystem.cpp
    index 107ce4f..5e30dec 100644
    a b uint myth_system(const QString &command, int flags) 
    9191        /* Attach stdin to /dev/null */
    9292        close(0);
    9393        int fd = open("/dev/null", O_RDONLY);
    94         dup2(fd, 0);
    95         if (fd != 0)
     94        if (fd > 0)
     95        {
     96            dup2(fd, 0);
    9697            close(fd);
     98        }
     99        else
     100        {
     101            VERBOSE(VB_IMPORTANT, (LOC_ERR + "open() failed because %1")
     102                    .arg(strerror(errno)));
     103        }
    97104
    98105        /* Run command */
    99106        execl("/bin/sh", "sh", "-c", command.toUtf8().constData(), NULL);