diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2021-11-19 00:39:39 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2021-11-19 00:39:39 +0000 |
commit | 055bdcea05ec69ce144e95cb4275c9c168f5ee50 (patch) | |
tree | caa9b40699f635c6927cd2263bc10f7f1dacf143 /converter/pbm/ybmtopbm.c | |
parent | 1f028a3d66db42414e29bb3c86b690f290e2af85 (diff) | |
download | netpbm-mirror-055bdcea05ec69ce144e95cb4275c9c168f5ee50.tar.gz netpbm-mirror-055bdcea05ec69ce144e95cb4275c9c168f5ee50.tar.xz netpbm-mirror-055bdcea05ec69ce144e95cb4275c9c168f5ee50.zip |
Release 10.86.26
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@4180 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/pbm/ybmtopbm.c')
-rw-r--r-- | converter/pbm/ybmtopbm.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/converter/pbm/ybmtopbm.c b/converter/pbm/ybmtopbm.c index 2a429086..ea7e66a7 100644 --- a/converter/pbm/ybmtopbm.c +++ b/converter/pbm/ybmtopbm.c @@ -20,44 +20,47 @@ static short const ybmMagic = ( ( '!' << 8 ) | '!' ); static void getinit(FILE * const ifP, - short * const colsP, - short * const rowsP, - short * const depthP) { + unsigned int * const colsP, + unsigned int * const rowsP, + int * const depthP) { - short magic; + short int magic; + short int cols, rows; int rc; rc = pm_readbigshort(ifP, &magic); if (rc == -1) pm_error("EOF / read error"); - - if (magic != ybmMagic) + else if (magic != ybmMagic) pm_error("bad magic number in YBM file"); - rc = pm_readbigshort(ifP, colsP); + rc = pm_readbigshort(ifP, &cols); if (rc == -1 ) pm_error("EOF / read error"); + else if (cols <= 0) + pm_error("invalid width value in YBM file"); - rc = pm_readbigshort(ifP, rowsP); + rc = pm_readbigshort(ifP, &rows); if (rc == -1) pm_error("EOF / read error"); + else if (rows <= 0) + pm_error("invalid height value in YBM file"); + *colsP = (unsigned int) cols; + *rowsP = (unsigned int) rows; *depthP = 1; } - - - int main(int argc, const char * argv[]) { FILE * ifP; bit * bitrow; - short rows, cols; + unsigned int rows, cols; unsigned int row; - short depth; + int depth; const char * inputFile; pm_proginit(&argc, argv); @@ -76,7 +79,7 @@ main(int argc, const char * argv[]) { getinit(ifP, &cols, &rows, &depth); if (depth != 1) - pm_error("YBM file has depth of %u, must be 1", (unsigned)depth); + pm_error("YBM file has depth of %u, must be 1", (unsigned int) depth); pbm_writepbminit(stdout, cols, rows, 0); |