transfig/CVE-2025-46398.patch

26 lines
926 B
Diff
Raw Permalink Normal View History

Origin:
https://sourceforge.net/p/mcj/tickets/191/
https://sourceforge.net/p/mcj/fig2dev/ci/5f22009dba73922e98d49c0096cece8b215cd45b/
--- a/fig2dev/read.c
+++ b/fig2dev/read.c
@@ -190,7 +190,8 @@
}
/* check for embedded '\0' */
- if (strlen(buf) < sizeof buf - 1 && buf[strlen(buf) - 1] != '\n') {
+ if (*buf == '\0' || (strlen(buf) < sizeof buf - 1 &&
+ buf[strlen(buf) - 1] != '\n')) {
put_msg("ASCII NUL ('\\0') character within the first line.");
exit(EXIT_FAILURE);
/* seek to the end of the first line
@@ -239,7 +240,7 @@
the encoding given in the file */
if (!input_encoding && !strcmp(buf, "encoding: UTF-8\n")) {
input_encoding = "UTF-8";
- } else if (buf[strlen(buf) - 1] != '\n') {
+ } else if (*buf == '\0' || buf[strlen(buf) - 1] != '\n') {
/* seek forward to the end of the line;
comments here are not mentioned by the
specification, thus ignore this comment */