payonel / ocvm

OpenComputer Emulator
40 stars 7 forks source link

String handling truncates at null characters #12

Closed Xaltonon closed 6 years ago

Xaltonon commented 6 years ago

Certain functions truncate at null characters when marshaling strings between Lua and C++. Both std::string and Lua strings may contain null characters, and this is relied on heavily when dealing with binary data in Lua. At least ValuePack::push_ret and Value::checkArg<string> do this, but I haven't had time to check the whole codebase.

I discovered this while implementing the datacard, thinking my cryptography library was broken. I'll submit a fix for the issues affecting that shortly.

payonel commented 6 years ago

don't use strings, use vector

payonel commented 6 years ago

example: https://github.com/payonel/ocvm/blob/master/apis/unicode.cpp#L390 that's pushing a vector