Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

Fix NPE in ClientToProxyConnection while closing the client connection#13

Merged
mjallday merged 1 commit into
verygoodsecurity:vgs-editionfrom
igor-dmitriev:keep-alive-npe
Jun 1, 2017
Merged

Fix NPE in ClientToProxyConnection while closing the client connection#13
mjallday merged 1 commit into
verygoodsecurity:vgs-editionfrom
igor-dmitriev:keep-alive-npe

Conversation

@igor-dmitriev
Copy link
Copy Markdown

@igor-dmitriev igor-dmitriev commented May 31, 2017

Fixes https://github.com/verygoodsecurity/vault/issues/1402

Due to currentHttpRequest can be null need to add not null verification, otherwise NPE can occurred.

https://github.com/adamfisk/LittleProxy/blob/master/src/main/java/org/littleshoot/proxy/impl/ProxyToServerConnection.java#L290

The currentHttpRequest goes the following route:

  1. https://github.com/adamfisk/LittleProxy/blob/master/src/main/java/org/littleshoot/proxy/impl/ProxyToServerConnection.java#L519
  2. https://github.com/adamfisk/LittleProxy/blob/master/src/main/java/org/littleshoot/proxy/impl/ClientToProxyConnection.java#L481
  3. https://github.com/adamfisk/LittleProxy/blob/master/src/main/java/org/littleshoot/proxy/impl/ClientToProxyConnection.java#L820
  4. https://github.com/adamfisk/LittleProxy/blob/master/src/main/java/org/littleshoot/proxy/impl/ClientToProxyConnection.java#L822
  5. As you can see in shouldCloseClientConnection when response is chunked not-null verification is present
    https://github.com/adamfisk/LittleProxy/blob/master/src/main/java/org/littleshoot/proxy/impl/ClientToProxyConnection.java#L858

but DOES NOT in keep alive checking

https://github.com/adamfisk/LittleProxy/blob/master/src/main/java/org/littleshoot/proxy/impl/ClientToProxyConnection.java#L869

that's why we got NPE

I've checked all other places where NPE can be raised as well, just need to fix it here.

ProxyToServerConnection

The current HTTP Request can be null when this proxy is
negotiating a CONNECT request with a chained proxy
while it is running as a MITM.

@igor-dmitriev igor-dmitriev changed the title Fix - NPE in ClientToProxyConnection while closing the client connection Fix NPE in ClientToProxyConnection while closing the client connection May 31, 2017
@mjallday
Copy link
Copy Markdown

👍 looks. can we get a test?

@igor-dmitriev
Copy link
Copy Markdown
Author

igor-dmitriev commented Jun 1, 2017

@mjallday I couldn't reproduce the issue locally, unfortunately :(
I was trying to create a test to catch this NPE

@mjallday mjallday merged commit 36d654b into verygoodsecurity:vgs-edition Jun 1, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants