зеркало из https://github.com/github/putty.git
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:
Родитель
c787e62651
Коммит
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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче