upstream commit

Add a couple of non-negativity checks to avoid close(-1).

ok djm

OpenBSD-Commit-ID: 4701ce0b37161c891c838d0931305f1d37a50880
This commit is contained in:
tb@openbsd.org 2018-02-05 05:37:46 +00:00 committed by Darren Tucker
parent 5069320be9
commit 3484380110
2 changed files with 12 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: monitor.c,v 1.178 2018/01/23 05:27:21 djm Exp $ */
/* $OpenBSD: monitor.c,v 1.179 2018/02/05 05:37:46 tb Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* Copyright 2002 Markus Friedl <markus@openbsd.org>
@ -289,7 +289,9 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
debug3("preauth child monitor started");
if (pmonitor->m_recvfd >= 0)
close(pmonitor->m_recvfd);
if (pmonitor->m_log_sendfd >= 0)
close(pmonitor->m_log_sendfd);
pmonitor->m_log_sendfd = pmonitor->m_recvfd = -1;
@ -371,8 +373,10 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
while (pmonitor->m_log_recvfd != -1 && monitor_read_log(pmonitor) == 0)
;
close(pmonitor->m_sendfd);
close(pmonitor->m_log_recvfd);
if (pmonitor->m_recvfd >= 0)
close(pmonitor->m_recvfd);
if (pmonitor->m_log_sendfd >= 0)
close(pmonitor->m_log_sendfd);
pmonitor->m_sendfd = pmonitor->m_log_recvfd = -1;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ssh-pkcs11-client.c,v 1.7 2017/05/30 08:52:19 markus Exp $ */
/* $OpenBSD: ssh-pkcs11-client.c,v 1.8 2018/02/05 05:37:46 tb Exp $ */
/*
* Copyright (c) 2010 Markus Friedl. All rights reserved.
*
@ -99,6 +99,7 @@ pkcs11_init(int interactive)
void
pkcs11_terminate(void)
{
if (fd >= 0)
close(fd);
}