mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00:00
Fix broken error path on open failure in PROXY_FUZZ.
We have to use the file name we just failed to open to format an error message _before_ freeing it, not after. If that use-after-free managed not to cause a crash, we'd also leak the file descriptor 'outfd'. Both spotted by Coverity (which is probably the first thing in years to look seriously at any of the code designed for Ben's AFL exercise).
This commit is contained in:
parent
c787e62651
commit
e82ba498ff
@ -88,8 +88,11 @@ Socket *platform_new_connection(SockAddr *addr, const char *hostname,
|
||||
}
|
||||
infd = open(cmd, O_RDONLY);
|
||||
if (infd == -1) {
|
||||
Socket *toret = new_error_socket_fmt(
|
||||
plug, "%s: %s", cmd, strerror(errno));
|
||||
sfree(cmd);
|
||||
return new_error_socket_fmt(plug, "%s: %s", cmd, strerror(errno));
|
||||
close(outfd);
|
||||
return toret;
|
||||
}
|
||||
sfree(cmd);
|
||||
inerrfd = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user