Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible null pointer dereference in ReceivingService #191

Closed
ghost opened this issue Oct 24, 2022 · 0 comments
Closed

Possible null pointer dereference in ReceivingService #191

ghost opened this issue Oct 24, 2022 · 0 comments

Comments

@ghost
Copy link

ghost commented Oct 24, 2022

The following code has a null guard for the _rsCfg argument, but the argument is used in both guarded and unguarded contexts:

    ReceivingService(ReceivingServiceConfig _rsCfg) {
        ReceivingServiceConfig rsCfg = Optional.ofNullable(_rsCfg).orElse(ReceivingServiceConfigBuilder.getDefaultConfig());
        executors.put(ExecutorNames.SIGNAL, Executors.newFixedThreadPool(rsCfg.getSignalThreadPoolSize(), new NameableThreadFactory("DBus-Signal-Receiver-", true)));
        executors.put(ExecutorNames.ERROR, Executors.newFixedThreadPool(rsCfg.getErrorThreadPoolSize(), new NameableThreadFactory("DBus-Error-Receiver-", true)));

        // we need multiple threads here so recursive method calls are possible
        executors.put(ExecutorNames.METHODCALL, Executors.newFixedThreadPool(rsCfg.getMethodCallThreadPoolSize(), new NameableThreadFactory("DBus-MethodCall-Receiver-", true)));
        executors.put(ExecutorNames.METHODRETURN, Executors.newFixedThreadPool(rsCfg.getMethodReturnThreadPoolSize(), new NameableThreadFactory("DBus-MethodReturn-Receiver-", true)));

        retryHandler = _rsCfg.getRetryHandler();
    }

The deprecated DirectConnection constructor passes in a null configuration, as per:

public DirectConnection(String _address, int _timeout) throws DBusException {
  this(createTransportConfig(_address, _timeout), null);
}

That null configuration is then passed along to:

protected AbstractConnection(TransportConfig _transportConfig, ReceivingServiceConfig _rsCfg) throws DBusException {

Then passed to ReceivingService via its constructor:

receivingService = new ReceivingService(_rsCfg);

This means that the following line can throw a NullPointerException:

retryHandler = _rsCfg.getRetryHandler();

Is this supposed to be called without the _ to use the null-safe variable? Such as:

retryHandler = rsCfg.getRetryHandler();
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

No branches or pull requests

0 participants