With the dynamic array sizes you cannot do simple tests to check the size of the incoming packets..basically you just have to trust that player is passing you a valid data packet. If you want to be double certain then you can test that it is at least the size of the base structure...
The len field in publish is actually ignored rather than being optional, The one in Request is also ignored, although it gets passed on for a long time first.
I'm trying to rewrite some plugin driver so it could be compiled with CVS
version of libplayercore. As we know, currently Publish() method parameter
that denotes the size of published data packet is optional and has default
value 0, which means, the size of the data can be dynamic and is computed.
In my driver I'm also using Request() method to send
PLAYER_SIMULATION_REQ_GET_POSE2D request, which means I have to fill
fields in player_simulation_pose2d_req_t structure. One of them (called
'name') has dynamic size. Unfortunately, 'len' parameter of Request()
method isn't optional, so I guess I have to pass size of the
My code is:
#define STRNCPY(dest, src, n) do \
strncpy(dest, src, n); \
((dest)[n-1]) = 0; \
} while (0)
Message * msg;
player_simulation_pose2d_req_t posreq, * posreq_new;
memset(&posdata, 0, sizeof posdata);
memset(&posreq, 0, sizeof posreq);
posreq.name_count = strlen(this->object) + 1;
posreq.name = new char[posreq.name_count ];
STRNCPY(posreq.name, this->object, posreq.name_count);
msg = this->simulation_dev->Request(this->InQueue,
posreq.name = NULL;
PLAYER_WARN("failed to acquire position data");
if ((msg->GetDataSize()) !=
PLAYER_WARN2("invalid acqired data size %d vs %d",
posreq_new = (player_simulation_pose2d_req_t
PLAYER_WARN("no data acquired");
posdata.pos.px = posreq_new->pose.px;
posdata.pos.py = posreq_new->pose.py;
posdata.pos.pa = posreq_new->pose.pa;
msg = NULL;
As a result I'm getting warning:
invalid acqired data size 35 vs 32
What went wrong?
This code worked before recent changes...
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
Playerstage-developers mailing list