From a68dd11b7dbd73684616d2b5116671ee85854056 Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Thu, 11 Mar 2021 23:48:40 +0000 Subject: Disable commands containing a character '|' for write18 in restricted mode for security. git-svn-id: svn://tug.org/texlive/trunk@58283 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/lib/ChangeLog | 5 +++++ Build/source/texk/web2c/lib/texmfmp.c | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Build/source/texk/web2c/lib/ChangeLog b/Build/source/texk/web2c/lib/ChangeLog index be05b6cdcee..17f829704e3 100644 --- a/Build/source/texk/web2c/lib/ChangeLog +++ b/Build/source/texk/web2c/lib/ChangeLog @@ -1,3 +1,8 @@ +2021-03-12 Akira Kakuto + + * texmfmp.c: Disable commands containing a character '|' for + write18 in restricted mode for security. + 2021-01-01 Akira Kakuto * printversion.c: Update copyright year. diff --git a/Build/source/texk/web2c/lib/texmfmp.c b/Build/source/texk/web2c/lib/texmfmp.c index 8b898176e8a..eeb32eaf22c 100644 --- a/Build/source/texk/web2c/lib/texmfmp.c +++ b/Build/source/texk/web2c/lib/texmfmp.c @@ -610,8 +610,18 @@ runsystem (const char *cmd) if (allow == 1) status = system (cmd); - else if (allow == 2) + else if (allow == 2) { +/* + command including a character '|' is not allowed in + restricted mode for security. +*/ + size_t k; + for (k = 0; k < strlen (safecmd); k++) { + if (safecmd[k] == '|') + return 0; + } status = system (safecmd); + } /* Not really meaningful, but we have to manage the return value of system. */ if (status != 0) -- cgit v1.2.3