1
0
mirror of https://github.com/XeonSquared/OC-Copper.git synced 2024-11-13 13:28:05 +11:00

Fix bug in cdlib where names could be accepted yet truncated.

This commit is contained in:
gamemanj 2017-03-28 10:30:01 +01:00
parent 82903d3655
commit d18c935db2
3 changed files with 5 additions and 2 deletions

View File

@ -18,6 +18,7 @@ local function decodeName(message)
if message:len() < 2 then return end
local nlen = message:byte(1) + 1
local fnam = message:sub(2, nlen + 1)
if fnam:len() < nlen then return end
return fnam, message:sub(nlen + 2)
end

View File

@ -27,7 +27,8 @@ TX.open(4957)
TB=TX.broadcast
function TN(m)
if#m<2then return end
local n=m:byte(1)+2return m:sub(2,n),m:sub(n+1)
local n,t=m:byte(1)+2t=m:sub(n+1)
if#t>=n then return m:sub(2,n),m:sub(n+1)end
end
function TR(m)
local h,s,m,d=m:byte(),TN(m:sub(2))

View File

@ -2,7 +2,8 @@ S,C,TC=string,component,"copper"
function CG(n)return C.proxy(C.list(n)())end
TH,TX=CG("eeprom").getLabel(),CG("modem")TX.open(4957)TB=TX.broadcast
function TN(m)if#m<2then return end
local n=m:byte(1)+2return m:sub(2,n),m:sub(n+1)end
local n,t=m:byte(1)+2t=m:sub(n+1)if#t>=n then return m:sub(2,n),m:sub(n+1)end
end
function TR(m)local h,s,m,d=m:byte(),TN(m:sub(2))if s then
d,m=TN(m)if d then
return s,d,m