resolve miminal issues - #19
Merged
Merged
Conversation
Signed-off-by: Brian Downs <brian.downs@gmail.com>
There was a problem hiding this comment.
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_endis computed viastrchr(rel_start, '"')even whenrel_startis NULL, and it currently finds the opening quote inrel="..."rather than the closing quote. This can crash on unexpected Link header formats and will truncaterelincorrectly.
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
bufferwith strtok/strsep, but libcurl does not guarantee the header callback buffer is NUL-terminated. This can read pasttotal_sizeand 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.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.