eclipse-wakaama / wakaama

Eclipse Wakaama is a C implementation of the Open Mobile Alliance's LightWeight M2M protocol (LWM2M).
BSD 3-Clause "New" or "Revised" License
501 stars 374 forks source link

Json serialization can not process empty string #475

Open xuyouming1986 opened 4 years ago

xuyouming1986 commented 4 years ago

I found that , when my resource is an empty string, then wakaama process json serialization fails. Any way, string resource can be empty, right?

res = json_escapeString(buffer + head, bufferLen - head, tlvP->value.asBuffer.buffer, tlvP->value.asBuffer.length); if (!res) return -1;

sbertin-telular commented 4 years ago

I'd recommend changing if (!res) return -1; to if (tlvP->value.asBuffer.length && !res) return -1;. when I get a chance I'll add test cases for empty strings for all formats and fix this on my version. I don't know when I'll be able to get it merged.

sbertin-telular commented 4 years ago

I already have fixed this in https://github.com/sbertin-telular/wakaama/tree/lwm2m_1.1. When pull requests start to be merged again I will submit my changes for merging also.

qleisan commented 3 years ago

@sbertin-telular possible for you to submit the fix?

sbertin-telular commented 3 years ago

If this is urgent, go ahead and submit a fix. I don't remember exactly where that change is and my changes for LWM2M 1.1 tend to build on each other. I can deal with the conflict when I get to my change.

qleisan commented 3 years ago

ok, it is not urgent. Just an ambition to reduce the number of open issues (bugs).