Hi, all
I have found the root cause why client parse failed for following scenario, the function prv_parseItem() will return failed if valueLen < 3, so my question is shoud client be able to parse
this scenario or reject ? I also commit an issue to leshan project.
static int prv_parseItem(uint8_t * buffer,
size_t bufferLen,
_record_t * recordP)
{
switch (tokenLen)
{
case 1:
{
switch (buffer[index+tokenStart])
{
case 'n':
{
int i;
int j;
if (recordP->ids[0] != LWM2M_MAX_ID) return -1;
// Check for " around URI
if (valueLen < 3
|| buffer[index+valueStart] != '"'
|| buffer[index+valueStart+valueLen-1] != '"')
{
return -1;
}
}
From: wakaama-dev-bounces@xxxxxxxxxxx <wakaama-dev-bounces@xxxxxxxxxxx>
On Behalf Of Zeng, Liang 1. (NSB - CN/Hangzhou)
Sent: Thursday, August 23, 2018 4:29 PM
To: Wakaama developer discussions <wakaama-dev@xxxxxxxxxxx>
Subject: Re: [wakaama-dev] test case failed , ask for help, thanks very much.
Hi, Greg,
Thanks for your kind help, and I found another json parse issue when integrate with leshan server, I write the package_URL to /5/0/1 by JSON format, and client parse failed, attachment is
the debug log from client.
The difference with
test_11 is that the value is empty for ānā as below, and I add test_13 for this scenario, and it failed. so I wonder whether the leshan server is reasonable
to send this kind of data, if so, then client need to handle it.
Leshan data : {"bn":"/5/0/1","e":[{"n":"","sv":"http"}]}
Test_11 data: {"bn":"/5/0/1","e":[{"n":"1","sv":"http"}]}
static void test_13(void)
failed
{
const char * buffer = "{\"bn\":\"/5/0/1\",\"e\":[{\"n\":\"\",\"sv\":\"http\"}]}";
test_raw(NULL, (uint8_t *)buffer, strlen(buffer), LWM2M_CONTENT_JSON, "13");
}
-----Original Message-----
From: wakaama-dev-bounces@xxxxxxxxxxx <wakaama-dev-bounces@xxxxxxxxxxx> On Behalf Of Gregory Lemercier
Sent: Wednesday, August 22, 2018 10:26 PM
To: Wakaama developer discussions <wakaama-dev@xxxxxxxxxxx>
Subject: Re: [wakaama-dev] test case failed , ask for help, thanks very much.
Hi Zeng,
I investigated your issue and found a bug in the JSON parsing code. I created a PR with your unit tests and the fix here:
https://github.com/eclipse/wakaama/pull/389
Everyone feel free to review and comment.
Thanks,
Greg
From: <wakaama-dev-bounces@xxxxxxxxxxx> on behalf of "Zeng, Liang 1. (NSB - CN/Hangzhou)" <liang.1.zeng@xxxxxxxxxxxxxxx>
Reply-To: Wakaama developer discussions <wakaama-dev@xxxxxxxxxxx>
Date: Wednesday 22 August 2018 at 11:14
To: "wakaama-dev@xxxxxxxxxxx" <wakaama-dev@xxxxxxxxxxx>
Subject: [wakaama-dev] test case failed , ask for help, thanks very much.
Resent-From: <g.lemercier@xxxxxxxxxxx>
Resent-Date: Wednesday 22 August 2018 at 11:14
Hi,
I try to add two test case as below, they have little difference(marked as yellow), one passed, and one failed, Does anybody know why ?
I think itās the basic function of LWM2M_CONTENT_JSON format.
static void test_11(void) failed(core dumped)
{ //{"bn":"/5/0/1","e":[{"n":"1","sv":"http"}]}
const char * buffer = "{\"bn\":\"/5/0/1\",\"e\":[{\"n\":\"/1\",\"sv\":\"http\"}]}";
test_raw(NULL, (uint8_t *)buffer, strlen(buffer), LWM2M_CONTENT_JSON, "11");
printf("\n test_11 ok \n");
}
static void test_12(void) passed
{ //{"bn":"/5/0/1","e":[{"n":"1","sv":"http"}]}
const char * buffer = "{\"bn\":\"/5/0\",\"e\":[{\"n\":\"/1\",\"sv\":\"http\"}]}";
test_raw(NULL, (uint8_t *)buffer, strlen(buffer), LWM2M_CONTENT_JSON, "11");
printf("\n test_11 ok \n");
}
BRs,
Zeng Liang
_______________________________________________
wakaama-dev mailing list
wakaama-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/wakaama-dev