droe / sslsplit

Transparent SSL/TLS interception
https://www.roe.ch/SSLsplit
BSD 2-Clause "Simplified" License
1.73k stars 327 forks source link

pxyconn.c: fix double free of host and serv variables #320

Closed disaykin closed 1 year ago

disaykin commented 1 year ago
When -1 is returned from sys_sockaddr_str, pointers in *host
and *serv are invalid and must not be used nor freed by the caller
sonertari commented 1 year ago

This is complicated. Because,

  1. We actually zero out ctx, so normally those are already NULL.
  2. I am not sure what happens in the case of protocol changes, such as passthrough mode. Because I am not sure if the code reaches there again (do we reinit logging?). And if it does reach there again, those are not NULL, and the fix you suggested would cause memory leak.
sonertari commented 1 year ago

I guess we should actually fix sys_sockaddr_str().

disaykin commented 1 year ago

I agree. Thanks.

sonertari commented 1 year ago

Thanks.