From: Michael R Sweet Date: Wed, 9 Jan 2019 18:19:11 +0000 (-0500) Subject: Protect against continuing to read from a file at EOF (Issue #5473) X-Git-Tag: v2.3b8~166 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96fee30386eebf99cda80c063591a1b1bc051907;p=thirdparty%2Fcups.git Protect against continuing to read from a file at EOF (Issue #5473) --- diff --git a/cups/file.c b/cups/file.c index 324abe26d4..e6e1f5b826 100644 --- a/cups/file.c +++ b/cups/file.c @@ -6,7 +6,7 @@ * our own file functions allows us to provide transparent support of * different line endings, gzip'd print files, PPD files, etc. * - * Copyright © 2007-2018 by Apple Inc. + * Copyright © 2007-2019 by Apple Inc. * Copyright © 1997-2007 by Easy Software Products, all rights reserved. * * Licensed under Apache License v2.0. See the file "LICENSE" for more @@ -675,6 +675,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... */ @@ -1647,6 +1653,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... */