From e3c883f91be7421e0822ec5fdc27099761a672f9 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sun, 7 Mar 2021 03:56:08 +0000 Subject: Release 10.86.19 git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@4037 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- doc/HISTORY | 14 ++++++++++++++ editor/pamscale.c | 26 +++++++++++++++++++------- lib/libsystem.c | 20 +++++++++++++++----- version.mk | 2 +- 4 files changed, 49 insertions(+), 13 deletions(-) diff --git a/doc/HISTORY b/doc/HISTORY index 12c6994b..7bf977f2 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -4,6 +4,20 @@ Netpbm. CHANGE HISTORY -------------- +21.03.07 BJH Release 10.86.19 + + pamscale: fix bogus "bad magic number" or similar failure most + of the time with -nomix. Broken since Netpbm 10.49 (December + 2009). + + libnetpbm: pm_system: Fix bug: standard input feeder process + repositions unrelated files. Always broken (pm_system was new + in Netpbm 10.13 (September 2003). + + Pamtowinicon: Fix crash or incorrect output with PNG encoding + (result of pm_system bug above). Always broken (Pamtowinicon + was new in Netpbm 10.63 (June 2013). + 20.12.08 BJH Release 10.86.18 pamarith: Fix bug: fails with more than two operands for diff --git a/editor/pamscale.c b/editor/pamscale.c index d8436689..410cd94a 100644 --- a/editor/pamscale.c +++ b/editor/pamscale.c @@ -2108,33 +2108,45 @@ scaleWithoutMixing(const struct pam * const inpamP, -----------------------------------------------------------------------------*/ tuple * tuplerow; /* An input row */ tuple * newtuplerow; - int row; - int rowInInput; + unsigned int row; + /* The number of the next row to be output */ + unsigned int rowInInput; + /* The number of the next row to be read from the input */ assert(outpamP->maxval == inpamP->maxval); assert(outpamP->depth == inpamP->depth); tuplerow = pnm_allocpamrow(inpamP); - rowInInput = -1; + rowInInput = 0; newtuplerow = pnm_allocpamrow(outpamP); for (row = 0; row < outpamP->height; ++row) { - int col; + unsigned int col; - int const inputRow = (int) (row / yscale); + unsigned int const inputRow = (int) (row / yscale); + /* The number of the input row that we will use for this output + row. + */ - for (; rowInInput < inputRow; ++rowInInput) + for (; rowInInput <= inputRow; ++rowInInput) pnm_readpamrow(inpamP, tuplerow); for (col = 0; col < outpamP->width; ++col) { - int const inputCol = (int) (col / xscale); + unsigned int const inputCol = (int) (col / xscale); pnm_assigntuple(inpamP, newtuplerow[col], tuplerow[inputCol]); } pnm_writepamrow(outpamP, newtuplerow); } + /* Read off and discard rest of rows, because whatever is supplying the + input stream may expect it to be consumed and because Caller will expect + the stream to be positioned to the next image. + */ + for (; rowInInput < inpamP->height; ++rowInInput) + pnm_readpamrow(inpamP, tuplerow); + pnm_freepamrow(tuplerow); pnm_freepamrow(newtuplerow); } diff --git a/lib/libsystem.c b/lib/libsystem.c index bf2416a4..91caf7e2 100644 --- a/lib/libsystem.c +++ b/lib/libsystem.c @@ -40,8 +40,8 @@ static void -closeUninheritableFds(int const stdinFd, - int const stdoutFd) { +closeUninheritableFds(int const keepFdA, + int const keepFdB) { /*---------------------------------------------------------------------------- Close all the file descriptors that we declare uninheritable -- files Parent has open that Child has no business accessing. @@ -49,14 +49,21 @@ closeUninheritableFds(int const stdinFd, Closing an extra file descriptor is essential to allow the file to close when Parent closes it. + It is also essential to prevent the system from messing with the position of + the file as the child process exits. If the file descriptor is backing a + stream (FILE *), some process-exit code seeks the file to the current stream + position (from the readahead position), but having the file descriptor + closed defeats that. + We define uninheritable as less than 64 and not Standard Input, Output, - or Error, or 'stdinFd' or 'stdoutFd'. + or Error, or 'keepFdA' or 'keepFdB'. -----------------------------------------------------------------------------*/ int fd; for (fd = 0; fd < 64; ++fd) { - if (fd == stdinFd) { - } else if (fd == stdoutFd) { + if (false) { + } else if (fd == keepFdA) { + } else if (fd == keepFdB) { } else if (fd == STDIN_FILENO) { } else if (fd == STDOUT_FILENO) { } else if (fd == STDERR_FILENO) { @@ -148,6 +155,9 @@ createPipeFeeder(void pipeFeederRtn(int, void *), } else if (rc == 0) { /* This is the child -- the stdin feeder process */ close(pipeToFeed[0]); + + closeUninheritableFds(pipeToFeed[1], pipeToFeed[1]); + (*pipeFeederRtn)(pipeToFeed[1], feederParm); exit(0); } else { diff --git a/version.mk b/version.mk index 07da05dd..d51677df 100644 --- a/version.mk +++ b/version.mk @@ -1,3 +1,3 @@ NETPBM_MAJOR_RELEASE = 10 NETPBM_MINOR_RELEASE = 86 -NETPBM_POINT_RELEASE = 18 +NETPBM_POINT_RELEASE = 19 -- cgit 1.4.1