From: Michael R Sweet Date: Wed, 9 Jan 2019 18:26:37 +0000 (-0500) Subject: Protect against continuing to read from a file at EOF (Issue #5473) X-Git-Tag: v2.2.11~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18518f3b94d1558357e4a2d7d81d3a0931fcde6b;p=thirdparty%2Fcups.git Protect against continuing to read from a file at EOF (Issue #5473) --- diff --git a/CHANGES.md b/CHANGES.md index 2ea55eff11..8e5d2bae8e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,4 @@ -CHANGES - 2.2.11 - 2018-12-14 +CHANGES - 2.2.11 - 2019-01-09 ============================= Changes in CUPS v2.2.11 @@ -6,6 +6,7 @@ Changes in CUPS v2.2.11 - Running ppdmerge with the same input and output filenames did not work as advertised (Issue #5455) +- Fixed a potential memory leak when reading at the end of a file (Issue #5473) - Fixed a potential crash bug in cups-driverd (rdar://46625579) diff --git a/cups/file.c b/cups/file.c index 5c9ddf8fe5..f67a6668e5 100644 --- a/cups/file.c +++ b/cups/file.c @@ -679,6 +679,12 @@ cupsFileGetChar(cups_file_t *fp) /* I - CUPS file */ return (-1); } + if (fp->eof) + { + DEBUG_puts("5cupsFileGetChar: End-of-file!"); + return (-1); + } + /* * If the input buffer is empty, try to read more data... */ @@ -1651,6 +1657,12 @@ cupsFileRead(cups_file_t *fp, /* I - CUPS file */ if (bytes == 0) return (0); + if (fp->eof) + { + DEBUG_puts("5cupsFileRead: End-of-file!"); + return (-1); + } + /* * Loop until all bytes are read... */