handle buffer space in rc_client image URL functions#498
Merged
Jamiras merged 1 commit intoRetroAchievements:developfrom Jan 31, 2026
Merged
handle buffer space in rc_client image URL functions#498Jamiras merged 1 commit intoRetroAchievements:developfrom
Jamiras merged 1 commit intoRetroAchievements:developfrom
Conversation
Since there is a status code return, indicate that the buffer was too small rather than silently truncating the URL.
There was a problem hiding this comment.
Pull request overview
This PR improves buffer handling in rc_client image URL functions by returning RC_INSUFFICIENT_BUFFER when the provided buffer is too small, instead of silently truncating URLs using snprintf. The implementation replaces snprintf with explicit length checking and memcpy for exact string copying.
Changes:
- Modified five image URL functions to check buffer size before copying and return
RC_INSUFFICIENT_BUFFERif insufficient - Added test coverage for buffer size validation in three test functions
- Ensures null terminator space is properly accounted for in buffer size checks
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/rc_client.c | Updated five functions (rc_client_get_image_url, rc_client_user_get_image_url, rc_client_game_get_image_url, and two paths in rc_client_achievement_get_image_url) to validate buffer size and return RC_INSUFFICIENT_BUFFER instead of silently truncating |
| test/test_rc_client.c | Added buffer size validation tests for user, game, and achievement image URL functions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Jamiras
approved these changes
Jan 24, 2026
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.
Since there is a status code return, indicate that the buffer was too small rather than silently truncating the URL.