fix: Off-by-one buffer errors in ircd_snprintf and ircd_strncpy calls#85
Open
MrLenin wants to merge 1 commit intoevilnet:masterfrom
Open
fix: Off-by-one buffer errors in ircd_snprintf and ircd_strncpy calls#85MrLenin wants to merge 1 commit intoevilnet:masterfrom
MrLenin wants to merge 1 commit intoevilnet:masterfrom
Conversation
ircd_snprintf(buf, size, ...) writes at most size-1 characters plus null. ircd_strncpy(dest, src, len) copies len-1 characters plus null. When a buffer is declared as buf[SIZE+1] to hold SIZE characters plus the null terminator, the copy function must be called with SIZE+1 as the length parameter, not SIZE. Fixed locations: - channel.c: find_ban() tmphost buffer for hidden host matching - m_userip.c: userip_formatter() iphost buffer (5 instances) - s_user.c: hide_hostmask() newhost buffer for account-based hiding - s_user.c: set_user_mode() account parsing with timestamped accounts The account parsing bug caused usernames like "ibutsu:1234567890" to be truncated to "ibuts" when received via P10 NICK burst with timestamp. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.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.
Summary
[SIZE+1]were passed toircd_snprintforircd_strncpywithSIZEinstead ofSIZE+1ircd_snprintf(0, buf, n, ...)writes at mostn-1characters plus null terminatorircd_strncpy(dest, src, n)copiesn-1characters plus null terminatorSIZEinstead ofSIZE+1truncates the last valid characterFiles Changed
tmphost[HOSTLEN+1]buffer inadd_banid()- fix snprintf sizeiphost[HOSTLEN+1]buffer - fix 5 snprintf callsnewhost[HOSTLEN+1]buffer inhide_hostmask()- fix 2 snprintf callsuser:1234567890) - fixircd_strncpylength calculationTest plan
🤖 Generated with Claude Code