diff options
author | Andreas Scherer <andreas_tex@freenet.de> | 2023-08-07 15:22:55 +0000 |
---|---|---|
committer | Andreas Scherer <andreas_tex@freenet.de> | 2023-08-07 15:22:55 +0000 |
commit | c747e5cdedb98f653cadc047c449c2d255a9253d (patch) | |
tree | 0a0c50d59951c938c96134929adac1c4fbcb19f6 /Build/source | |
parent | 37c1807d8ef20c6ab0bd4428e81cb4bc6244a429 (diff) |
[CWEB] Max out the section depth in CWEAVE/CTWILL.
CWEAVE didn't check for malicious user input like @*1234567890123456,
which certainly would over-/underflow INT_MAX. :o)
git-svn-id: svn://tug.org/texlive/trunk@67831 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r-- | Build/source/texk/web2c/cwebdir/cweave.w | 7 | ||||
-rw-r--r-- | Build/source/texk/web2c/cwebdir/system.bux | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/Build/source/texk/web2c/cwebdir/cweave.w b/Build/source/texk/web2c/cwebdir/cweave.w index fff90af9ca2..9a83e4410ef 100644 --- a/Build/source/texk/web2c/cwebdir/cweave.w +++ b/Build/source/texk/web2c/cwebdir/cweave.w @@ -110,6 +110,11 @@ file |"common.h"|, which is also included in |"common.w"| to propagate possible changes from this \.{COMMON} interface consistently. @i common.h +\.{CWEAVE} will use the |INT_MAX| limit in section +|@<Output the code for the beginning...@>| below. + +@<Incl...@>= +#include <limits.h> @* Data structures exclusive to {\tt CWEAVE}. As explained in \.{common.w}, the field of a |name_info| structure @@ -4237,7 +4242,7 @@ else { } else { for (sec_depth=0; xisdigit(*loc);loc++) - sec_depth = sec_depth*10 + (*loc) -'0'; + if (sec_depth < INT_MAX / 10) sec_depth = sec_depth*10 + (*loc) -'0'; } while (*loc == ' ') loc++; /* remove spaces before group title */ group_found=true; diff --git a/Build/source/texk/web2c/cwebdir/system.bux b/Build/source/texk/web2c/cwebdir/system.bux index 52877fd11dd..2210e39ed24 100644 --- a/Build/source/texk/web2c/cwebdir/system.bux +++ b/Build/source/texk/web2c/cwebdir/system.bux @@ -51,6 +51,8 @@ @$gettext "<libintl.h>" \zip@> @$textdomain "<libintl.h>" \zip@> +@$INT_MAX "<limits.h>" \zip@> + @$bindtextdomain "<locale.h>" \zip@> @$setlocale "<locale.h>" \zip@> @$LC_CTYPE "<locale.h>" \zip@> |