Summary: | source/fitz/error.c: use fz_write_printf instead of fprintf | ||
---|---|---|---|
Product: | MuPDF | Reporter: | josch |
Component: | fitz | Assignee: | MuPDF bugs <mupdf-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | kurtin |
Priority: | P4 | ||
Version: | unspecified | ||
Hardware: | PC | ||
OS: | Linux | ||
Customer: | Word Size: | --- | |
Attachments: | source/fitz/error.c: use fz_write_printf instead of fprintf |
Description
josch
2019-06-23 06:55:09 UTC
This could cause problems with loops, if fz_write_printf itself were to throw an exception. fz_vsnprintf is already used in error.c and as far as I can see uses the same code as fz_write_printf, namely fz_format_string. How does the current code guard against loops created by fz_vsnprintf throwing an error? fz_vsnprintf is safe (an evidenced by the fact that it doesn't take a fz_context). Writing the resulting string to a fz_output object could throw in fz_write_byte calleb dy the fz_write_emit callback used by fz_write_printf. I have added two functions to provide custom error/warning callbacks which should provide a safer mechanism for redirecting error messages. commit 6d28dcdedc68b3303a519fcf92536bfcfaa4f15f Author: Tor Andersson <tor.andersson@artifex.com> Date: Mon Jun 24 11:37:42 2019 +0200 Bug 701263: Provide error/warning callback methods. In order to override the default behaviour of printing to stdout, we provide user callbacks for emitting error and warning messages. The default implementation prints to stderr on all platforms. On Windows, it also uses OutputDebugString in debug builds. On Android, it also uses the Android logging mechanisms. commit 6d28dcdedc68b3303a519fcf92536bfcfaa4f15f Author: Tor Andersson <tor.andersson@artifex.com> Date: Mon Jun 24 11:37:42 2019 +0200 Bug 701263: Provide error/warning callback methods. In order to override the default behaviour of printing to stdout, we provide user callbacks for emitting error and warning messages. The default implementation prints to stderr on all platforms. On Windows, it also uses OutputDebugString in debug builds. On Android, it also uses the Android logging mechanisms. *** Bug 697973 has been marked as a duplicate of this bug. *** |