diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2017-04-16 20:24:44 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2017-04-16 20:24:44 +0000 |
commit | 7c605e807606003cfe752c195762467dfe6398bc (patch) | |
tree | 086fb18f2c35d6d5b2f2819676a5f919ddb33341 | |
parent | 24af8ee36d4be2640f5406fc9dd45689e70329fa (diff) | |
download | netpbm-mirror-7c605e807606003cfe752c195762467dfe6398bc.tar.gz netpbm-mirror-7c605e807606003cfe752c195762467dfe6398bc.tar.xz netpbm-mirror-7c605e807606003cfe752c195762467dfe6398bc.zip |
Improve error message for purported image that ends in the middle of the magic number
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2954 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r-- | doc/HISTORY | 4 | ||||
-rw-r--r-- | lib/pmfileio.c | 15 |
2 files changed, 15 insertions, 4 deletions
diff --git a/doc/HISTORY b/doc/HISTORY index 51629cb9..6bb5a44f 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -8,6 +8,10 @@ not yet BJH Release 10.79.00 Add pamtable . + libnetpbm: Improve error message for purported image that is + exactly 1 byte long (so ends in the middle of what would be the + magic number). + pamcomp: fix incorrect output with -mixtransparency. Always broken. (-mixtransparency was new in Netpbm 10.56, September 2011). diff --git a/lib/pmfileio.c b/lib/pmfileio.c index 035037ba..cfdac10d 100644 --- a/lib/pmfileio.c +++ b/lib/pmfileio.c @@ -774,11 +774,18 @@ pm_readmagicnumber(FILE * const ifP) { int ich1, ich2; ich1 = getc(ifP); + + if (ich1 == EOF) + pm_error("Error reading first byte of what is expected to be " + "a Netpbm magic number. " + "Most often, this means your input file is empty"); + ich2 = getc(ifP); - if (ich1 == EOF || ich2 == EOF) - pm_error( "Error reading magic number from Netpbm image stream. " - "Most often, this " - "means your input file is empty." ); + + if (ich2 == EOF) + pm_error("Error reading second byte of what is expected to be " + "a Netpbm magic number (the first byte was successfully " + "read as 0x%02x)", ich1); return ich1 * 256 + ich2; } |