View Issue Details

IDProjectCategoryView StatusLast Update
0001269Spring engineUnit Scriptingpublic2009-01-16 13:20
ReporterEvil4Zerggin Assigned Toimbaczek  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version0.77b5 
Summary0001269: Null Characters Break LuaMsg
DescriptionIf you send a string containing null characters (which does not terminate the string in Lua) via LuaMsg, anything after the first null character gets received as garbage. This poses problems for transmission of binary data. I'm not sure how easy or hard it is to fix this.

Demo widget to come.
TagsNo tags attached.
Checked infolog.txt for Errors

Activities

Evil4Zerggin

2009-01-16 10:53

reporter   ~0003181

Warning: This will spam you.

----------------------------------------------------------------

function widget:GetInfo()
  return {
    name = "Test",
    desc = "NT",
    author = "E4Z",
    date = "NA",
    license = "PD",
    layer = 1,
    enabled = false -- loaded by default?
  }
end

function widget:Update(dt)
    local msg = "abc\000abc"
    Spring.SendLuaUIMsg(msg, "a")
    Spring.Echo("Sent", string.byte(msg, 1, string.len(msg)))
end

function widget:RecvLuaMsg(msg)
    Spring.Echo("Recv", string.byte(msg, 1, string.len(msg)))
end

----------------------------------------------------------------

Output:

[ 0] Sent, 97, 98, 99, 0, 97, 98, 99
[ 0] Recv, 97, 98, 99, 0, 0, 144, 4
[ 0] Sent, 97, 98, 99, 0, 97, 98, 99
[ 0] Sent, 97, 98, 99, 0, 97, 98, 99
[ 0] Recv, 97, 98, 99, 0, 255, 118, 0
[ 0] Recv, 97, 98, 99, 0, 0, 200, 37
and so on.

imbaczek

2009-01-16 13:12

reporter   ~0003182

RecvLuaMsg is null-proof, but send isn't. fix on the way.

Issue History

Date Modified Username Field Change
2009-01-16 10:44 Evil4Zerggin New Issue
2009-01-16 10:53 Evil4Zerggin Note Added: 0003181
2009-01-16 13:12 imbaczek Note Added: 0003182
2009-01-16 13:20 imbaczek Status new => resolved
2009-01-16 13:20 imbaczek Resolution open => fixed
2009-01-16 13:20 imbaczek Assigned To => imbaczek