Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Adding basic support for length delimited strings #889

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ste-lam
Copy link

@ste-lam ste-lam commented Aug 31, 2024

This PR adds basic support for applications that do not use c-strings but length delimited strings.
Here you need to create a temporary c-string copy to transfer the string to cjson.

To avoid this superfluous temporary copy, this PR adds two new public functions (with new tests):

  • cJSON_CreateRawWithLength: create a cJSON_Raw from a length delimited input string
  • cJSON_CreateStringWithLength: create a cJSON_String from a length delimited input string

JSON_AddXToObject functions have intentionally not been added. Nullbytes are still interpreted as null-termination, which is limitation as long as cjson uses c-strings internally.

 - cJSON_CreateRawWithLength: create a cJSON_Raw from a length limited input string
 - cJSON_CreateStringWithLength: create a cJSON_String from a length limited input string
@ste-lam ste-lam changed the base branch from master to develop September 2, 2024 20:23
@ste-lam ste-lam changed the base branch from develop to master September 2, 2024 20:24
added null check
@ste-lam
Copy link
Author

ste-lam commented Sep 26, 2024

Can somebody check why CIFuzz / Fuzzing does not work?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant