diff options
| author | Toomas Soome <tsoome@me.com> | 2019-03-04 15:54:04 +0200 |
|---|---|---|
| committer | Toomas Soome <tsoome@me.com> | 2019-03-26 20:24:53 +0200 |
| commit | f7e4f33f27df122daef98e5b4b537dc159597da5 (patch) | |
| tree | 54831060f6e1c6bf9009627e87f0b24a5c96d908 /usr | |
| parent | 61233e713d6c3509d5c076a791c0c2c09cf5cb76 (diff) | |
| download | illumos-joyent-f7e4f33f27df122daef98e5b4b537dc159597da5.tar.gz | |
10580 pnglite: unchecked function return
Reviewed by: John Levon <john.levon@joyent.com>
Reviewed by: Rob Johnston <rob.johnston@joyent.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Diffstat (limited to 'usr')
| -rw-r--r-- | usr/src/common/pnglite/pnglite.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/usr/src/common/pnglite/pnglite.c b/usr/src/common/pnglite/pnglite.c index 59b9df1db6..7a30bdc609 100644 --- a/usr/src/common/pnglite/pnglite.c +++ b/usr/src/common/pnglite/pnglite.c @@ -99,12 +99,13 @@ png_get_bpp(png_t *png) static int png_read_ihdr(png_t *png) { - unsigned length; + unsigned length = 0; unsigned orig_crc; unsigned calc_crc; uint8_t ihdr[13+4]; /* length should be 13, make room for type (IHDR) */ - file_read_ul(png, &length); + if (file_read_ul(png, &length) != PNG_NO_ERROR) + return (PNG_FILE_ERROR); if (length != 13) return (PNG_CRC_ERROR); @@ -112,7 +113,8 @@ png_read_ihdr(png_t *png) if (file_read(png, ihdr, 1, 13+4) != 13+4) return (PNG_EOF_ERROR); - file_read_ul(png, &orig_crc); + if (file_read_ul(png, &orig_crc) != PNG_NO_ERROR) + return (PNG_FILE_ERROR); calc_crc = crc32(0L, Z_NULL, 0); calc_crc = crc32(calc_crc, ihdr, 13+4); @@ -219,7 +221,7 @@ done: if (result != PNG_NO_ERROR) { free(png->image); - close(png->fd); + (void) close(png->fd); png->fd = -1; return (result); } @@ -230,7 +232,7 @@ done: int png_close(png_t *png) { - close(png->fd); + (void) close(png->fd); png->fd = -1; free(png->image); png->image = NULL; @@ -328,7 +330,8 @@ png_read_idat(png_t *png, unsigned length) calc_crc = crc32(calc_crc, (uint8_t *)"IDAT", 4); calc_crc = crc32(calc_crc, (uint8_t *)png->readbuf, length); - file_read_ul(png, &orig_crc); + if (file_read_ul(png, &orig_crc) != PNG_NO_ERROR) + return (PNG_FILE_ERROR); if (orig_crc != calc_crc) return (PNG_CRC_ERROR); @@ -343,9 +346,10 @@ png_process_chunk(png_t *png) unsigned type; unsigned length; - file_read_ul(png, &length); + if (file_read_ul(png, &length) != PNG_NO_ERROR) + return (PNG_FILE_ERROR); - if (file_read_ul(png, &type)) + if (file_read_ul(png, &type) != PNG_NO_ERROR) return (PNG_FILE_ERROR); /* @@ -372,7 +376,7 @@ png_process_chunk(png_t *png) } else if (type == png_IEND) return (PNG_DONE); else - file_read(png, 0, 1, length + 4); /* unknown chunk */ + (void) file_read(png, 0, 1, length + 4); /* unknown chunk */ return (result); } @@ -570,7 +574,7 @@ png_get_data(png_t *png, uint8_t *data) png->readbuflen = 0; } if (png->zs) - png_end_inflate(png); + (void) png_end_inflate(png); if (result != PNG_DONE) { free(png->png_data); |
