sfree(disp->hostname);
sfree(disp->unixsocketpath);
if (disp->localauthdata)
- memset(disp->localauthdata, 0, disp->localauthdatalen);
+ smemclr(disp->localauthdata, disp->localauthdatalen);
sfree(disp->localauthdata);
if (disp->remoteauthdata)
- memset(disp->remoteauthdata, 0, disp->remoteauthdatalen);
+ smemclr(disp->remoteauthdata, disp->remoteauthdatalen);
sfree(disp->remoteauthdata);
sfree(disp->remoteauthprotoname);
sfree(disp->remoteauthdatastring);
done:
fclose(authfp);
- memset(buf, 0, 65537 * 4);
+ smemclr(buf, 65537 * 4);
sfree(buf);
sfree(ourhostname);
}
{
struct X11Private *pr = (struct X11Private *) plug;
- /*
- * We have no way to communicate down the forwarded connection,
- * so if an error occurred on the socket, we just ignore it
- * and treat it like a proper close.
- *
- * FIXME: except we could initiate a full close here instead of
- * just an outgoing EOF? ssh.c currently has no API for that, but
- * it could.
- */
- sshfwd_write_eof(pr->c);
+ if (error_msg) {
+ /*
+ * Socket error. Slam the connection instantly shut.
+ */
+ sshfwd_unclean_close(pr->c);
+ } else {
+ /*
+ * Ordinary EOF received on socket. Send an EOF on the SSH
+ * channel.
+ */
+ if (pr->c)
+ sshfwd_write_eof(pr->c);
+ }
+
return 1;
}