diff --git a/svr-chansession.c b/svr-chansession.c
index a040a47b92e09d43cac716d1605eae9e734c67ef..1704c6efca9dc5290e73c161991866277f6e5062 100644
--- a/svr-chansession.c
+++ b/svr-chansession.c
@@ -837,7 +837,7 @@ static void execchild(struct ChanSess *chansess) {
 
 	/* close file descriptors except stdin/stdout/stderr
 	 * Need to be sure FDs are closed here to avoid reading files as root */
-	for (i = 3; i < (unsigned int)ses.maxfd; i++) {
+	for (i = 3; i <= (unsigned int)ses.maxfd; i++) {
 		if (m_close(i) == DROPBEAR_FAILURE) {
 			dropbear_exit("Error closing file desc");
 		}