~gpcf/advtrains-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH] [security] small security fixes in advtrains_luaautomation/

Details
Message ID
<20221124132554.2135-1-git.maverick2797@gmail.com>
DKIM signature
missing
Download raw message
Patch: +1 -1
 - fixed file permissions of advtrains_luaautomation/README.md (755->644)
 - fixed file permissions of advtrains_luaautomation/environment.lua (755->644)
 - prevented LuaATC section_occupancy() from having direct access to the interlocking section id occupancy table
---
 advtrains_luaautomation/README.md       | 0
 advtrains_luaautomation/environment.lua | 2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
 mode change 100755 => 100644 advtrains_luaautomation/README.md
 mode change 100755 => 100644 advtrains_luaautomation/environment.lua

diff --git a/advtrains_luaautomation/README.md b/advtrains_luaautomation/README.md
old mode 100755
new mode 100644
diff --git a/advtrains_luaautomation/environment.lua b/advtrains_luaautomation/environment.lua
old mode 100755
new mode 100644
index 6b1a283..fddcc8e
--- a/advtrains_luaautomation/environment.lua
+++ b/advtrains_luaautomation/environment.lua
@@ -232,7 +232,7 @@ if advtrains.interlocking then
		if response == nil then
			return false
		else
			return response.trains
			return table.copy(response.trains or {})
		end
	end
end
-- 
2.38.0
Details
Message ID
<9877abb7-fb0a-4f46-6ad1-d495a66d90b6@forksworld.de>
In-Reply-To
<20221124132554.2135-1-git.maverick2797@gmail.com> (view parent)
DKIM signature
missing
Download raw message
>   		if response == nil then
>   			return false
>   		else
> -			return response.trains
> +			return table.copy(response.trains or {})
>   		end

Would it make sense to check the response using `not response` instead 
of `response == nil`? That would avoid the `or {}` part in the modified 
line.

This is not introduced by the patch, but does it make any (significant) 
difference whether the track section ID is falsy (false or nil) or 
refers to a non-existent track section? Otherwise I don't see why the 
former case returns nil while the latter returns false.

The patch looks good otherwise.

[PATCH v2] [security] small security fixes in advtrains_luaautomation/

Details
Message ID
<20221125103810.14229-1-git.maverick2797@gmail.com>
In-Reply-To
<20221124132554.2135-1-git.maverick2797@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Patch: +2 -5
 - fixed file permissions of advtrains_luaautomation/README.md (755->644)
 - fixed file permissions of advtrains_luaautomation/environment.lua (755->644)
 - prevented LuaATC section_occupancy() from having direct access to the interlocking section id occupancy table
 - simplify section_occupancy() logic
---
 advtrains_luaautomation/README.md       | 0
 advtrains_luaautomation/environment.lua | 7 ++-----
 2 files changed, 2 insertions(+), 5 deletions(-)
 mode change 100755 => 100644 advtrains_luaautomation/README.md
 mode change 100755 => 100644 advtrains_luaautomation/environment.lua

diff --git a/advtrains_luaautomation/README.md b/advtrains_luaautomation/README.md
old mode 100755
new mode 100644
diff --git a/advtrains_luaautomation/environment.lua b/advtrains_luaautomation/environment.lua
old mode 100755
new mode 100644
index 6b1a283..d85bedc
--- a/advtrains_luaautomation/environment.lua
+++ b/advtrains_luaautomation/environment.lua
@@ -229,11 +229,8 @@ if advtrains.interlocking then
		if not ts_id then return nil end
		ts_id = tostring(ts_id)
		local response = advtrains.interlocking.db.get_ts(ts_id)
		if response == nil then
			return false
		else
			return response.trains
		end
		if not response then return false end
		return table.copy(response.trains)
	end
end

-- 
2.38.0
Reply to thread Export thread (mbox)