summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2019-01-09 13:26:37 -0500
committerDidier Raboud <odyx@debian.org>2018-12-14 13:58:47 +0100
commit5b2890774c0879bd62ee4abb6c8d87e5c6abcb36 (patch)
treef7a42b2ded64f8c2887da6d5234b3496ffa94636
parentf67a4b249a53f91ecb70dce59a8c41ca1c3b04ed (diff)
Protect against continuing to read from a file at EOF (Issue #5473)
Fixed a potential memory leak when reading at the end of a file
-rw-r--r--cups/file.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/cups/file.c b/cups/file.c
index 5c9ddf8fe..f67a6668e 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...
*/