Skip to content

High: canseelogin() Unsafe String Comparison #2

@smooge

Description

@smooge

Priority: HIGH
File: Src/checkX.c
Function: canseelogin()
Discovered: During unit testing of access control logic

Description: Function performs strcmp() without NULL checks on loginname global variable, potentially causing crashes if loginname is uninitialized.

Reproduction Steps:

  1. Set loginname global variable to NULL
  2. Set world.hide_login = 1
  3. Call canseelogin()
  4. Crashes due to strcmp(NULL, LOGIN)

Impact: Server crashes if loginname is not properly initialized, affecting system stability.

Proposed Fix: Add NULL safety checks:

int canseelogin(void) {
    if (loginname == NULL) {
        return 0;  /* Fail safe - deny access if user unknown */
    }
    return (!world.hide_login ||
            (strcmp(loginname, LOGIN) == 0) ||
            (strcmp(loginname, world.demigod) == 0));
}

Original Bug ID: BUG-002

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmodernizationIssues related to C code modernizationsecuritySecurity vulnerabilities and fixes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions