about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2009-12-29 20:15:07 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2009-12-29 20:15:07 +0000
commit0a727692cbd0157ef468716c2444aa19d8ed4154 (patch)
treec72e8f359f59234c4c4c8783e82cf5a36ff695d8
parentf7d95b861fc144bdcc1688b5864aaab27fecec3e (diff)
downloadnetpbm-mirror-0a727692cbd0157ef468716c2444aa19d8ed4154.tar.gz
netpbm-mirror-0a727692cbd0157ef468716c2444aa19d8ed4154.tar.xz
netpbm-mirror-0a727692cbd0157ef468716c2444aa19d8ed4154.zip
Release 10.47.07
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@1076 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--converter/ppm/xpmtoppm.c5
-rw-r--r--doc/HISTORY14
-rw-r--r--editor/pnmsmooth.c2
-rw-r--r--lib/libpamread.c9
-rw-r--r--lib/libsystem.c146
-rw-r--r--version.mk2
6 files changed, 149 insertions, 29 deletions
diff --git a/converter/ppm/xpmtoppm.c b/converter/ppm/xpmtoppm.c
index 5884d3d4..67a76eab 100644
--- a/converter/ppm/xpmtoppm.c
+++ b/converter/ppm/xpmtoppm.c
@@ -162,7 +162,7 @@ static unsigned int
 getNumber(char * const p, unsigned int const size) {
 
     unsigned int retval;
-    char * q;
+    unsigned char * q;
     
     retval = 0;
     for (q = p; q < p+size; ++q)
@@ -466,7 +466,8 @@ readXpm1Header(FILE * const stream, int * const widthP, int * const heightP,
     char line[MAX_LINE+1], str1[MAX_LINE+1], str2[MAX_LINE+1];
     char *t1;
     char *t2;
-    int format, v;
+    int format;
+    unsigned int v;
     int i, j;
     bool processedStaticChar;  
         /* We have read up to and interpreted the "static char..." line */
diff --git a/doc/HISTORY b/doc/HISTORY
index b633df2b..91996402 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -4,6 +4,20 @@ Netpbm.
 CHANGE HISTORY 
 --------------
 
+09.12.29 BJH  Release 10.47.07
+
+              libnetpbm: When reading plain format PNM with PAM routines,
+              validate pixel against maxval (necessary for integer non-overrun
+              guarantees).
+
+              xpmtoppm: fix wild pointer with color index > 127.
+
+              pnmsmooth: fix incorrect call to pm_system_lp() that makes
+              it never work (but it wouldn't anyway because pm_system_lp()
+              was broken -- see below).
+
+              pm_system*: fix various bugs that make it never work.
+
 09.12.10 BJH  Release 10.47.06
 
               pamtosvg: fix compile failure from 10.47.05.
diff --git a/editor/pnmsmooth.c b/editor/pnmsmooth.c
index fa525e14..16d8ec33 100644
--- a/editor/pnmsmooth.c
+++ b/editor/pnmsmooth.c
@@ -201,7 +201,7 @@ main(int argc, char ** argv) {
         /* We're done.  Convolution image is in user's file */
     } else {
         pm_system_lp("pnmconvol", NULL, NULL, NULL, NULL,
-                     tempfileName, cmdline.inputFilespec, NULL);
+                     "pnmconvol", tempfileName, cmdline.inputFilespec, NULL);
 
         unlink(tempfileName);
         strfree(tempfileName);
diff --git a/lib/libpamread.c b/lib/libpamread.c
index f4d85493..0506d020 100644
--- a/lib/libpamread.c
+++ b/lib/libpamread.c
@@ -71,9 +71,14 @@ readPlainNonPbmRow(const struct pam * const pamP,
     for (col = 0; col < pamP->width; ++col) {
         unsigned int plane;
         for (plane = 0; plane < pamP->depth; ++plane)
-            if (tuplerow)
+            if (tuplerow) {
                 tuplerow[col][plane] = pm_getuint(pamP->file);
-            else
+
+                if (tuplerow[col][plane] > pamP->maxval)
+                    pm_error("Plane %u sample value %lu exceeds the "
+                             "image maxval of %lu",
+                             plane, tuplerow[col][plane], pamP->maxval);
+            } else
                 pm_getuint(pamP->file);  /* read data and discard */
     }
 }
diff --git a/lib/libsystem.c b/lib/libsystem.c
index f0a1996a..2ce9b743 100644
--- a/lib/libsystem.c
+++ b/lib/libsystem.c
@@ -49,33 +49,41 @@ execProgram(const char *  const progName,
 -----------------------------------------------------------------------------*/
     int stdinSaveFd, stdoutSaveFd;
     int rc;
+    int execErrno;
 
     /* Make stdinFd Standard Input.
        Make stdoutFd Standard Output.
     */
-    stdinSaveFd = dup(STDIN);
-    stdoutSaveFd = dup(STDOUT);
-    
-    close(STDIN);
-    close(STDOUT);
-
-    dup2(stdinFd, STDIN);
-    dup2(stdoutFd, STDOUT);
+    if (stdinFd != STDIN) {
+        stdinSaveFd  = dup(STDIN);
+        close(STDIN);
+        dup2(stdinFd, STDIN);
+    }
+    if (stdoutFd != STDOUT) {
+        stdoutSaveFd = dup(STDOUT);
+        close(STDOUT);
+        dup2(stdoutFd, STDOUT);
+    }
 
     rc = execvp(progName, (char **)argArray);
 
-    close(STDIN);
-    close(STDOUT);
-    dup2(stdinSaveFd, STDIN);
-    dup2(stdoutSaveFd, STDOUT);
-    close(stdinSaveFd);
-    close(stdoutSaveFd);
+    execErrno = errno;
 
+    if (stdinFd != STDIN) {
+        close(STDIN);
+        dup2(stdinSaveFd, STDIN);
+        close(stdinSaveFd);
+    }
+    if (stdoutFd != STDOUT) {
+        close(STDOUT);
+        dup2(stdoutSaveFd, STDOUT);
+        close(stdoutSaveFd);
+    }
     if (rc < 0)
         pm_error("Unable to exec '%s' "
                  "(i.e. the program did not run at all).  "
                  "execvp() errno=%d (%s)",
-                 progName, errno, strerror(errno));
+                 progName, execErrno, strerror(execErrno));
     else
         pm_error("INTERNAL ERROR.  execvp() returns, but does not fail.");
 }
@@ -135,7 +143,8 @@ spawnProcessor(const char *  const progName,
    descriptor of the other end of that pipe, from which Caller can
    suck the program's Standard Output.
 -----------------------------------------------------------------------------*/
-    bool const pipeStdout = !stdoutFdP;
+    bool const pipeStdout = !!stdoutFdP;
+
     int stdoutpipe[2];
     pid_t rc;
 
@@ -144,7 +153,7 @@ spawnProcessor(const char *  const progName,
 
     rc = fork();
     if (rc < 0) {
-        pm_error("fork() of processor process failed.  errno=%d (%s)\n", 
+        pm_error("fork() of processor process failed.  errno=%d (%s)", 
                  errno, strerror(errno));
     } else if (rc == 0) {
         /* The program child */
@@ -175,14 +184,103 @@ spawnProcessor(const char *  const progName,
 }
 
 
+
+static const char *
+signalName(unsigned int const signalClass) {
+
+    if (signalClass <= SIGSYS) {
+        switch (signalClass) {
+        case SIGHUP:
+            return "SIGHUP";
+        case SIGINT:
+            return "SIGINT";
+        case SIGQUIT:
+            return "SIGQUIT";
+        case SIGILL:
+            return "SIGILL";
+        case SIGTRAP:
+            return "SIGTRAP";
+        case SIGABRT:
+            return "SIGABRT";
+        case SIGBUS:
+            return "SIGBUS";
+        case SIGFPE:
+            return "SIGFPE";
+        case SIGKILL:
+            return "SIGKILL";
+        case SIGUSR1:
+            return "SIGUSR1";
+        case SIGSEGV:
+            return "SIGSEGV";
+        case SIGUSR2:
+            return "SIGUSR2";
+        case SIGPIPE:
+            return "SIGPIPE";
+        case SIGALRM:
+            return "SIGALRM";
+        case SIGTERM:
+            return "SIGTERM";
+        case SIGCHLD:
+            return "SIGCHLD";
+        case SIGCONT:
+            return "SIGCONT";
+        case SIGSTOP:
+            return "SIGSTOP";
+        case SIGTSTP:
+            return "SIGTSTP";
+        case SIGTTIN:
+            return "SIGTTIN";
+        case SIGTTOU:
+            return "SIGTTOU";
+        case SIGURG:
+            return "SIGURG";
+        case SIGXCPU:
+            return "SIGXCPU";
+        case SIGXFSZ:
+            return "SIGXFSZ";
+        case SIGVTALRM:
+            return "SIGVTALRM";
+        case SIGPROF:
+            return "SIGPROF";
+        case SIGWINCH:
+            return "SIGWINCH";
+        case SIGIO:
+            return "SIGIO";
+        case SIGPWR:
+            return "SIGPWR";
+        case SIGSYS:
+            return "SIGSYS";
+        default:
+            return "???";
+        }
+    } else if ((int)signalClass >= SIGRTMIN && (int)signalClass <= SIGRTMAX)
+        return "SIGRTxxx";
+    else
+        return "???";
+}
+
+
+
 static void
 cleanupProcessorProcess(pid_t const processorPid) {
 
-    int status;
-    waitpid(processorPid, &status, 0);
-    if (status != 0) 
-        pm_message("Shell process ended abnormally.  "
-                   "completion code = %d", status);
+    int terminationStatus;
+    waitpid(processorPid, &terminationStatus, 0);
+
+    if (WIFEXITED(terminationStatus)) {
+        int const exitStatus = WEXITSTATUS(terminationStatus);
+
+        if (exitStatus != 0)
+            pm_message("Shell process exited with abnormal exit status %u.  ",
+                       exitStatus);
+    } else if (WIFSIGNALED(terminationStatus)) {
+        pm_message("Shell process was killed by a Class %u (%s) signal.",
+                   WTERMSIG(terminationStatus),
+                   signalName(WTERMSIG(terminationStatus)));
+    } else {
+        pm_message("Shell process died, but its termination status "
+                   "0x%x  doesn't make sense", terminationStatus);
+    }
 }
 
 
@@ -234,8 +332,10 @@ pm_system_vp(const char *    const progName,
    But if 'stdinFeeder' is NULL, just feed the program our own Standard
    Input.  And if 'stdoutFeeder' is NULL, just send its Standard Output
    to our own Standard Output.
------------------------------------------------------------------------------*/
 
+   Run the program 'progName' with arguments argArray[] (terminated by NULL
+   element).  That includes arg0.
+-----------------------------------------------------------------------------*/
     /* If 'stdinFeeder' is non-NULL, we create a child process to run
        'stdinFeeder' and create a pipe from that process as the
        program's Standard Input.
diff --git a/version.mk b/version.mk
index 153518ab..5e252304 100644
--- a/version.mk
+++ b/version.mk
@@ -1,4 +1,4 @@
 NETPBM_MAJOR_RELEASE = 10
 NETPBM_MINOR_RELEASE = 47
-NETPBM_POINT_RELEASE = 6
+NETPBM_POINT_RELEASE = 7