ccn-lite icon indicating copy to clipboard operation
ccn-lite copied to clipboard

issue in ccnl_mkSimpleContent

Open mfrey opened this issue 6 years ago • 6 comments

Hi,

I've encountered an issue while using ccnl_mkContentObject. Basically, the pointer to the content (returned via the function) does not match the content I've passed to the function. I've started to narrow it down and basically there seems to be something wrong with

315     c_p->content = c_p->buf->data + dataoffset;

Unfortunately, copy/paste in my VM setup does not work, but I basically provided my own local producer function which in turn calls ccnl_mkSimpleContent. The following screenshot depicts an interest /foo/bar which triggers the call of my local producer which tries to create content. The content is set to "RIOT!" (meaning no matter which name you pass via an interest, it will always create a corresponding NDO containing a "RIOT!" string).

image

What you notice is that the offset is 25 while the actual content is at offset 18. Speaking again about the listing above, the data in c_p->content is not pointing to actual data I've passed to ccnl_mkSimpleContent.

First, am I missing something? Second, can somebody confirm this behaviour?

TIA

mfrey avatar Mar 01 '18 16:03 mfrey

I've uploaded the code for this example over here.

mfrey avatar Mar 01 '18 16:03 mfrey

In order to compile your example I had to apply some changes: https://gist.github.com/OlegHahm/5c6034994e324f6c2769c00fc6802f7a and build with WERROR=0.

OlegHahm avatar Mar 04 '18 18:03 OlegHahm

Since there seems to be no documentation on ccnl_mkSimpleContent() it's hard to tell what the parameter payoffset is supposed to contain. However, it seems that it is set to the offset within the ccnl_buf_s struct, not the actual data buffer (buf->data).

So, yes, I can confirm the behavior. Yes, it is confusing. No, I have no idea what was the intentions (if any) behind that.

OlegHahm avatar Mar 04 '18 20:03 OlegHahm

I can also confirm the behavior, but I have no idea, why it is like it is. Christian implemented that.

blacksheeep avatar Mar 07 '18 10:03 blacksheeep

So we can agree that It is pointing to the wrong position in the buffer and make it a bug?

mfrey avatar Mar 07 '18 10:03 mfrey

Yes, I think so

blacksheeep avatar Mar 07 '18 10:03 blacksheeep