-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG][C] The bundled cJSON is an old version, and it should be a library dependency anyway #20431
Comments
I understand the point, but I'm worried we'll end up having to tell the users to build cJSON themselves, since it doesn't seem to be as widely available as curl. On macos for example, it would seem to require homebrew. Also the project itself endorses copying the source like this: https://github.com/DaveGamble/cJSON?tab=readme-ov-file#copying-the-source. Maybe we could just upgrade to a newer version? (Assuming that we have bugs here) |
I don't think that's the case. On Linux libcjson is definitely in every package repository out there. The GitHub macOS runner already has Homebrew installed by default, and the C examples link against the Homebrew OpenSSL:
I don't personally interpret that as an endorsement. It reads more like a "yes, it's OK" note to those who prefer to copy the source files. But this is splitting hairs anyway, as any Open Source library can be copied as source just as well.
Regardless of every other decision: yes, the first thing should be to just update the current sources in the repo. There are even CVEs in the current old version. Side note about cJSON: I don't like it that much. Or maybe "like" is the wrong verb: I don't trust it. It doesn't actually comply with the JSON specification because its UTF-8 parsing is broken. And then there are other issues. For example its development seems to be nearly dead right now, and one of the last PRs that was accepted into is Undefined Behavior: DaveGamble/cJSON#924 ...but I'm not suggesting it should be replaced with some other library. I don't know what would be a better choice, I haven't vetted all of the available ones. Just wanted to point this out. |
Ok, but I think most macos installations don't, and some users may not want to install it. Also my point isn't really about macos, that was just an example. I just don't know where this thing will be built or run, so I'd rather not add a new dependency if it can be helped.
Openssl is an optional dependency and it only seems to be used for base64 encoding/decoding, so plenty of things should still work without it. (By the way, I find it excessive to have a dependency for that alone, we could just reimplement base64 and get rid of openssl entirely.)
I agree that this isn't a great look for cjson; but if the project is indeed dead, then that means there's pretty much no advantage to dynamic linking. |
Oh definitely. Base64 is not that complicated. |
Currently cJSON is just a copy of the v1.7.7 sources (with a few typo fixes in comments). It's old (2018) and not used like a library dependency really should. It should be dynamically linked like is already done with OpenSSL and libcurl.
Word diff of upstream cJSON v1.7.7 and openapi-generator's bundled copy:
Here's the script from the screenshot:
The text was updated successfully, but these errors were encountered: