Skip to content

mod.ccontrol: EVT_NETJOIN dereferences the result of findServer() without a null check #93

Description

@MrIron-no

In ccontrol::OnEvent()'s EVT_NETJOIN case (mod.ccontrol/ccontrol.cc:1111):

        iServer* UplinkServer = Network->findServer(NewServer->getUplinkIntYY());
        ccServer* CheckServer = getServer(NewServer->getName());
        inBurst = true;
        if (!CheckServer) {
            MsgChanLog("Unknown server just connected: %s via %s\n", NewServer->getName().c_str(),
                       UplinkServer->getName().c_str());
        } else {
            CheckServer->setLastConnected(::time(0));
            CheckServer->setUplink(UplinkServer->getName());

xNetwork::findServer() returns null when the numeric is not in the server map, and UplinkServer is dereferenced in both branches (ccontrol.cc:1130 and :1133) with no check. CheckServer, fetched on the line below it, is checked — so the omission looks accidental.

Whether the uplink can genuinely be missing at this point depends on the order in which the server map is populated during a net join; if it cannot, the dereference is safe today but rests on an invariant nothing states or enforces.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions