[gs-commits] mupdf 1.16.1.epub-prerelease-35 Fix a possible buffer ove
[email protected] (Paul Gardiner) Thu, 2 Jan 2020 12:50:34 +0000 (UTC)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 7d3e75c0eb2b5a8d2e57e11419838f5bf0777676 Author: Paul Gardiner <[email protected]> Date: Thu Dec 12 13:37:43 2019 +0000 Fix a possible buffer overflow There are places where we call strlen on a buffer after initialising it with pdf_format_date. When strftime returns 0, it may leave the buffer underfined. This commit ensures the buffer is always initialised. diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c index ff7722d..2c13ff5 100644 --- a/source/pdf/pdf-annot.c +++ b/source/pdf/pdf-annot.c @@ -1435,9 +1435,14 @@ pdf_format_date(fz_context *ctx, char *s, int n, time_t secs) struct tm *tm = gmtime(&secs); #endif if (!tm) + { fz_strlcpy(s, "D:19700101000000Z", n); + } else - strftime(s, n, "D:%Y%m%d%H%M%SZ", tm); + { + if (!strftime(s, n, "D:%Y%m%d%H%M%SZ", tm) && n > 0) + s[0] = '\0'; + } } static int64_t http://git.ghostscript.com/?p=mupdf.git;a=commit;h=7d3e75c0eb2b5a8d2e57e11419838f5bf0777676 -- MuPDF library Artifex Software, Inc.