Skip to content

resolve miminal issues - #19

Merged
briandowns merged 6 commits into
masterfrom
make_safer
Jul 20, 2026
Merged

resolve miminal issues#19
briandowns merged 6 commits into
masterfrom
make_safer

Conversation

@briandowns

Copy link
Copy Markdown
Owner

No description provided.

Signed-off-by: Brian Downs <brian.downs@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes small cleanup and safety-focused updates to the C GitHub API client header and implementation, including API surface adjustments and more defensive parsing/NULL handling.

Changes:

  • Adjusts the public header layout/API (include guard positioning, removes/renames some exported items).
  • Adds defensive checks and memory initialization in the client implementation.
  • Refactors pagination Link header parsing to avoid modifying const input.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
github.h Public header/API adjustments (include guard placement, removed constants/types, stargazers function name fix).
github.c Adds curl handle reset in macro, adds NULL checks, and updates Link/rate-limit header parsing and response initialization.
Comments suppressed due to low confidence (2)

github.c:170

  • parse_link_header() can segfault and also mis-parse the rel value: rel_end is computed via strchr(rel_start, '"') even when rel_start is NULL, and it currently finds the opening quote in rel="..." rather than the closing quote. This can crash on unexpected Link header formats and will truncate rel incorrectly.
        char *url_start = strchr(token, '<');
        char *url_end = strchr(token, '>');
        char *rel_start = strstr(token, "rel=\"");
        char *rel_end = strchr(rel_start, '\"');

github.c:218

  • header_cb() parses buffer with strtok/strsep, but libcurl does not guarantee the header callback buffer is NUL-terminated. This can read past total_size and cause undefined behavior. Copy the header chunk into a local NUL-terminated buffer before tokenizing.
    size_t total_size = size * nmemb;
    gh_client_response_t *response = (gh_client_response_t*)userdata;

    char *line = strtok(buffer, "\r\n");
    char *key = strsep(&line, ":");

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread github.c
Comment thread github.c
Comment thread github.h
Comment thread github.h
Comment thread github.h
Signed-off-by: Brian Downs <brian.downs@gmail.com>
Signed-off-by: Brian Downs <brian.downs@gmail.com>
Signed-off-by: Brian Downs <brian.downs@gmail.com>
Signed-off-by: Brian Downs <brian.downs@gmail.com>
Signed-off-by: Brian Downs <brian.downs@gmail.com>
@briandowns
briandowns merged commit 0a5d0a6 into master Jul 20, 2026
2 of 6 checks passed
@briandowns
briandowns deleted the make_safer branch July 20, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants