Skip to content
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

c3c unable to use compressed curl library - JSON parsing bug with bad uncompressed line endings #1490

Closed
joshring opened this issue Sep 26, 2024 · 4 comments
Assignees
Labels
Bug Something isn't working Fixed Needs Verification Fixed, but needs verification that it works

Comments

@joshring
Copy link
Contributor

joshring commented Sep 26, 2024

c3c_cannot_use_compressed_curl.zip

Example is attached

Example works when uncompressed curl.c3l directory is used

curl obtained from

c3c vendor-fetch curl

Platform:
Ubuntu Linux 24.04.1 LTS

Code being used to test the library

module playground;
import std::io;
import curl;
import libc;

fn int main()
{

    void*! curl;

    curl::CURLcode! res;

    curl = curl::easy_init();
    defer (void)curl::easy_cleanup(curl); // always cleanup

    if (try curl) {

        curl::easy_setopt(curl, curl::CURLOPT_URL, "https://www.example.com/");
        res = curl::easy_perform(curl);

        if (try res && res == curl::CURLcode.CURLE_OK)
        {
            char*! content_type;
            // ask for the content-type
            res = curl::easy_getinfo(curl, curl::CURLINFO_CONTENT_TYPE, &content_type)!!;

            if (try content_type)
            {
                io::printfn("We received Content-Type: %s", *content_type);
            }
        }
    }

    return 0;
}

Underlying bug

More like the json parser [for manifest.json when compressed]
There was some bug reaching the end of the file. I saw it, but forgot to file an issue to fix it.
If you uncompress it with some tools, it might change the line endings

@joshring joshring changed the title c3c unable to use compressed curl library c3c unable to use compressed curl library - JSON parsing bug with uncompressed line endings Sep 26, 2024
@joshring joshring changed the title c3c unable to use compressed curl library - JSON parsing bug with uncompressed line endings c3c unable to use compressed curl library - JSON parsing bug with bad uncompressed line endings Sep 26, 2024
@lerno lerno self-assigned this Sep 29, 2024
@lerno lerno added Bug Something isn't working Fixed Needs Verification Fixed, but needs verification that it works labels Sep 29, 2024
@lerno
Copy link
Collaborator

lerno commented Sep 29, 2024

It turns out this was another bug. When reading a zip file, it would read the whole uncompressed length BUT not leave a final zero terminating byte. This caused the json parser to overrun its buffer, which in this case happened to be the string buffer, so it would sometimes work and sometimes not.

@lerno
Copy link
Collaborator

lerno commented Sep 29, 2024

It should be fixed now.

@joshring
Copy link
Contributor Author

Awesome! All good

@lerno
Copy link
Collaborator

lerno commented Sep 29, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Fixed Needs Verification Fixed, but needs verification that it works
Projects
None yet
Development

No branches or pull requests

2 participants