]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: Check fd against >=0 instead of >0 in error path. The
authordtucker@openbsd.org <dtucker@openbsd.org>
Fri, 31 Mar 2023 00:44:29 +0000 (00:44 +0000)
committerDamien Miller <djm@mindrot.org>
Fri, 31 Mar 2023 04:06:19 +0000 (15:06 +1100)
dup could in theory return fd 0 although currently it doesn't in practice.
From Dmitry Belyavskiy vi github PR#238.

OpenBSD-Commit-ID: 4a95f3f7330394dffee5c749d52713cbf3b54846

monitor_wrap.c

index 275171168059574e16d0f7418c293f57a834a1ca..3533cf0692c085cf27a77f6e3438a2839db3403f 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: monitor_wrap.c,v 1.127 2023/03/30 00:49:37 dtucker Exp $ */
+/* $OpenBSD: monitor_wrap.c,v 1.128 2023/03/31 00:44:29 dtucker Exp $ */
 /*
  * Copyright 2002 Niels Provos <provos@citi.umich.edu>
  * Copyright 2002 Markus Friedl <markus@openbsd.org>
@@ -575,7 +575,7 @@ mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen)
        if ((tmp1 = dup(pmonitor->m_recvfd)) == -1 ||
            (tmp2 = dup(pmonitor->m_recvfd)) == -1) {
                error_f("cannot allocate fds for pty");
-               if (tmp1 > 0)
+               if (tmp1 >= 0)
                        close(tmp1);
                return 0;
        }