From f1a09fe49db5ee123c3edd34aa88e8bb03231ede Mon Sep 17 00:00:00 2001 From: Hisham Muhammad <hisham@gobolinux.org> Date: Mon, 11 Apr 2022 17:12:16 -0300 Subject: patch: fix check for malformed patches --- src/luarocks/tools/patch.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua index cc5293d3..6f36d713 100644 --- a/src/luarocks/tools/patch.lua +++ b/src/luarocks/tools/patch.lua @@ -540,7 +540,8 @@ local function write_new_file(filename, hunk) local fh = io.open(filename, "wb") if not fh then return false end for _, hline in ipairs(hunk.text) do - if hline:sub(1,1) ~= "+" then + local c = hline:sub(1,1) + if c ~= "+" and c ~= "-" and c ~= " " then return false, "malformed patch" end fh:write(hline:sub(2)) -- cgit v1.2.3-55-g6feb