aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2024-08-26 12:05:01 -0300
committerHisham Muhammad <hisham@gobolinux.org>2024-08-27 11:32:08 -0300
commitbdb7345a28f9b8d3edba46ac0dc5cfbd57cb92e8 (patch)
treec7e7cd9b5480fb412c18cd000ec266d368ae2d63 /src
parentd300c11c6acba4390fdde9030a45b0a31e7501d1 (diff)
downloadluarocks-bdb7345a28f9b8d3edba46ac0dc5cfbd57cb92e8.tar.gz
luarocks-bdb7345a28f9b8d3edba46ac0dc5cfbd57cb92e8.tar.bz2
luarocks-bdb7345a28f9b8d3edba46ac0dc5cfbd57cb92e8.zip
fix: patch: check array indices correctly
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/tools/patch.lua9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua
index 6f36d713..10654e06 100644
--- a/src/luarocks/tools/patch.lua
+++ b/src/luarocks/tools/patch.lua
@@ -11,7 +11,6 @@
11local patch = {} 11local patch = {}
12 12
13local fs = require("luarocks.fs") 13local fs = require("luarocks.fs")
14local fun = require("luarocks.fun")
15 14
16local io = io 15local io = io
17local os = os 16local os = os
@@ -255,7 +254,7 @@ function patch.read_patch(filename, data)
255 local advance 254 local advance
256 if state == 'filenames' then 255 if state == 'filenames' then
257 if startswith(line, "--- ") then 256 if startswith(line, "--- ") then
258 if fun.contains(files.source, nextfileno) then 257 if files.source[nextfileno] then
259 all_ok = false 258 all_ok = false
260 warning(format("skipping invalid patch for %s", 259 warning(format("skipping invalid patch for %s",
261 files.source[nextfileno+1])) 260 files.source[nextfileno+1]))
@@ -278,7 +277,7 @@ function patch.read_patch(filename, data)
278 table.insert(files.source, match) 277 table.insert(files.source, match)
279 end 278 end
280 elseif not startswith(line, "+++ ") then 279 elseif not startswith(line, "+++ ") then
281 if fun.contains(files.source, nextfileno) then 280 if files.source[nextfileno] then
282 all_ok = false 281 all_ok = false
283 warning(format("skipping invalid patch with no target for %s", 282 warning(format("skipping invalid patch with no target for %s",
284 files.source[nextfileno+1])) 283 files.source[nextfileno+1]))
@@ -289,7 +288,7 @@ function patch.read_patch(filename, data)
289 end 288 end
290 state = 'header' 289 state = 'header'
291 else 290 else
292 if fun.contains(files.target, nextfileno) then 291 if files.target[nextfileno] then
293 all_ok = false 292 all_ok = false
294 warning(format("skipping invalid patch - double target at line %d", 293 warning(format("skipping invalid patch - double target at line %d",
295 lineno+1)) 294 lineno+1))
@@ -331,7 +330,7 @@ function patch.read_patch(filename, data)
331 if not advance and state == 'hunkhead' then 330 if not advance and state == 'hunkhead' then
332 local m1, m2, m3, m4 = match_linerange(line) 331 local m1, m2, m3, m4 = match_linerange(line)
333 if not m1 then 332 if not m1 then
334 if not fun.contains(files.hunks, nextfileno-1) then 333 if not files.hunks[nextfileno-1] then
335 all_ok = false 334 all_ok = false
336 warning(format("skipping invalid patch with no hunks for file %s", 335 warning(format("skipping invalid patch with no hunks for file %s",
337 files.target[nextfileno])) 336 files.target[nextfileno]))