You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use long consistently for user mode bitmasks - #271
Use long consistently for user mode bitmasks and related temporary values.
Client->umode and other user-mode storage are already defined as long, while several parts of the user-mode handling pipeline still used int or unsigned int intermediates.
This change makes those paths type-consistent without changing user-visible behaviour.
Changes
Change user_modes[] from int to long
Use long for user-mode flags and mode-table pointers
Use long for saved oldumode values
Update send_umode_out() to accept a long mode mask
Keep non-bitmask control variables such as what, i, and badflag as int
Affected areas include:
NICK handling
WHO / RWHO
server propagation
Services mode handling
MODE processing
Why
Bahamut stores user modes in long, but several intermediate variables still used narrower integer types.
Keeping the full user-mode pipeline consistent with the underlying storage avoids narrowing/sign issues and makes the mode system safer for future bit assignments.
This does not add a new user mode and does not change current user-visible behaviour.
Testing
Tested against a standalone Bahamut 2.2.4 instance.
Full build completed successfully
Final ircd binary linked successfully
git diff --check passed
User MODE query passed
MODE set/unset passed
User modes were preserved across nick changes
WHO passed with two connected clients
WHOIS passed in both directions
No crashes or malformed mode output observed
+H could not be fully exercised because hostmasking was not enabled in the standalone test configuration; the server correctly returned the existing hostmasking-disabled notice.
Scope
This is a type-consistency / portability cleanup. No current upstream security exploitability is being claimed.
Thanks, this looks good. I built it and ran it on a local 3-server network (one hub, two leaves, with plain, zip and TLS links). The build has the same 15 warnings as master, and linking, bursts, NICK/MODE propagation and WHOIS between servers all work.
It covers every loop over user_modes, plus send_umode_out, rwho_opts.umodes, oldumode/setflags and m_oper's saved mode. That's every int intermediate I could find.
One request: please update the WARNING: Do not add any values greater than 0x40000000 ... comment in include/struct.h. This is the PR that makes bit 31 (0x80000000L) safe to use, so the warning is out of date once it lands.
This change also matters for #267. With #267 on its own, RWHO m p finds no users. The int umodes[2] mask turns bit 31 into a sign-extended negative value, so the "has all these modes" check never matches. With this PR's long umodes[2] it works. I'd suggest merging this first and rebasing #267 on top.
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
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
Use
longconsistently for user mode bitmasks and related temporary values.Client->umodeand other user-mode storage are already defined aslong, while several parts of the user-mode handling pipeline still usedintorunsigned intintermediates.This change makes those paths type-consistent without changing user-visible behaviour.
Changes
user_modes[]frominttolonglongfor user-mode flags and mode-table pointerslongfor savedoldumodevaluessend_umode_out()to accept alongmode maskwhat,i, andbadflagasintAffected areas include:
Why
Bahamut stores user modes in
long, but several intermediate variables still used narrower integer types.Keeping the full user-mode pipeline consistent with the underlying storage avoids narrowing/sign issues and makes the mode system safer for future bit assignments.
This does not add a new user mode and does not change current user-visible behaviour.
Testing
Tested against a standalone Bahamut 2.2.4 instance.
ircdbinary linked successfullygit diff --checkpassed+Hcould not be fully exercised because hostmasking was not enabled in the standalone test configuration; the server correctly returned the existing hostmasking-disabled notice.Scope
This is a type-consistency / portability cleanup. No current upstream security exploitability is being claimed.