fengyouchao / sockslib

A Java library of SOCKS5 protocol including client and server
Apache License 2.0
284 stars 104 forks source link

Added check for null in CommandMessage.getLength #10

Closed reikje closed 6 years ago

reikje commented 6 years ago

I have run some tests and in cases where getBytes() returned null, the addressType has been 0. Since addressType is set in read() it is likely that socksException has also been set (I didn't verify this).

So an alternative solution might be to check for the exception between these two lines:

@Override
public int read(ReadableMessage message) throws SocksException, IOException {
  message.read(inputStream);
  return message.getLength();
}

On the other hand, it doesn't look like any caller of read(..) is using the return value? So we might as well return void instead and no longer do the return message.getLength(); call.

fengyouchao commented 6 years ago

Thank you for your PR.

reikje commented 6 years ago

No problem. You can close https://github.com/fengyouchao/sockslib/issues/9 I guess :)