mirror of
				https://github.com/minetest-mods/mesecons.git
				synced 2025-11-04 12:55:29 +01:00 
			
		
		
		
	microcontroller: fix unsafe pattern usage (#620)
This commit is contained in:
		@@ -332,7 +332,8 @@ yc.parse_get_eeprom_param = function(cond, starti)
 | 
			
		||||
	local addr
 | 
			
		||||
	while s ~= "" do
 | 
			
		||||
		s = string.sub(cond, i, i)
 | 
			
		||||
		if string.find("0123456789", s) == nil or s == "" then
 | 
			
		||||
		local b = s:byte()
 | 
			
		||||
		if s == "" or 48 > b or b > 57 then
 | 
			
		||||
			addr = string.sub(cond, starti, i-1) -- i: last number i+1 after last number
 | 
			
		||||
			return addr, i
 | 
			
		||||
		end
 | 
			
		||||
@@ -419,13 +420,16 @@ yc.command_sbi = function(params, eeprom, L, Lv)
 | 
			
		||||
 | 
			
		||||
	if status == nil then return nil, nil end
 | 
			
		||||
 | 
			
		||||
	if string.find("ABCD", params[1])~=nil and #params[1]==1 then --is a port
 | 
			
		||||
		if status == "1" then
 | 
			
		||||
			Lv = yc.set_portstate (params[1], true,  Lv)
 | 
			
		||||
		else
 | 
			
		||||
			Lv = yc.set_portstate (params[1], false, Lv)
 | 
			
		||||
	if #params[1]==1 then
 | 
			
		||||
		local b = params[1]:byte()
 | 
			
		||||
		if 65 <= b and b <= 68 then -- is a port
 | 
			
		||||
			if status == "1" then
 | 
			
		||||
				Lv = yc.set_portstate (params[1], true,  Lv)
 | 
			
		||||
			else
 | 
			
		||||
				Lv = yc.set_portstate (params[1], false, Lv)
 | 
			
		||||
			end
 | 
			
		||||
			return eeprom, Lv;
 | 
			
		||||
		end
 | 
			
		||||
		return eeprom, Lv;
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	--is an eeprom address
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user