Skip to content

Use long consistently for user mode bitmasks - #271

Merged
eaescob merged 1 commit into
DALnet:masterfrom
Jazzzzz-hub:usermode-bitmask-long
Oct 14, 2026
Merged

eaescob merged 1 commit into
DALnet:masterfrom
Jazzzzz-hub:usermode-bitmask-long

Conversation

@Jazzzzz-hub

Copy link
Copy Markdown
Contributor

Summary

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.

@devin-ai-integration

Copy link
Copy Markdown

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.

Written by Devin

@eaescob eaescob self-assigned this Oct 14, 2026
@eaescob
eaescob merged commit fc3d398 into DALnet:master Oct 14, 2026
1 check 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.

2 participants