2025-08-01 19:09 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0001269Spring engineUnit Scriptingpublic2009-01-16 13:20
ReporterEvil4Zerggin 
Assigned Toimbaczek 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version0.77b5 
Target VersionFixed in Version 
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
Attached Files

-Relationships
+Relationships

-Notes

~0003181

Evil4Zerggin (reporter)

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.

~0003182

imbaczek (reporter)

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

-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
+Issue History