Closed opandad closed 1 year ago
Write for the first time, sorry!
Run it in ubuntu20.04, Intel cpu
#include <iostream>
#include <sstream>
#include <msgpack.hpp>
int main(){
std::string testStr = "";
for(int i = 0; i < 70000; i++){
char a[70001] = {};
testStr += 'a';
std::stringstream ss;
msgpack::pack(ss, testStr);
std::string temp = ss.str();
strcat(a, temp.c_str());
if(strlen(a) <= 2){
std::cout << i+1 << std::endl;
}
}
return 0;
}
The packed data is MessagePack formatted byte data. It is different from the original (before packed) data. See https://github.com/msgpack/msgpack/blob/master/spec.md#str-format-family
It would contain any binary byte 0x00..0xff. So strlen() doesn't work well.
How can I do let it work well, or how can I know the strlen().
I want to split it when after pack the str data.How can I do?
I don't know why you cancat packed data. Simply don't concat, then you can get splitted packed data.
Or unpack with offset https://github.com/msgpack/msgpack-c/wiki/v2_0_cpp_unpacker
Maybe you need to laern a lot of things before using msgpack-c. For example, non-null terminated string behavior. strcat is also unreliable in this case.
I get it, thank you!
Describe the bug It will output null data after pack data which length 256, 512, 1024, 2048.
msgpack-cxx 3.3.0 and msgpack-cxx 6.0.0
To Reproduce
I test in local, find out pack.hpp when l != 2^n, buf[2] will = 'd'; when l = 2^n, buf[2] will = 2
And I hardcode buf[2] = 'd', c_str() is normal.
Expected behavior Can output the data when after pack data