Skip to content

handle buffer space in rc_client image URL functions#498

Merged
Jamiras merged 1 commit intoRetroAchievements:developfrom
stenzek:get-image-url
Jan 31, 2026
Merged

handle buffer space in rc_client image URL functions#498
Jamiras merged 1 commit intoRetroAchievements:developfrom
stenzek:get-image-url

Conversation

@stenzek
Copy link
Contributor

@stenzek stenzek commented Jan 23, 2026

Since there is a status code return, indicate that the buffer was too small rather than silently truncating the URL.

Since there is a status code return, indicate that the buffer was too
small rather than silently truncating the URL.
Copilot AI review requested due to automatic review settings January 23, 2026 15:07
Copy link

Copilot AI left a comment

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 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_BUFFER if 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 Jamiras added this to the 12.3 milestone Jan 24, 2026
@Jamiras Jamiras merged commit 7506ef1 into RetroAchievements:develop Jan 31, 2026
11 of 12 checks passed
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.

3 participants