From: dtucker@openbsd.org Date: Fri, 31 Mar 2023 04:42:29 +0000 (+0000) Subject: upstream: Return immediately from get_sock_port X-Git-Tag: V_9_4_P1~98 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6f0308a3e717ebe68eeb3f95253612fab5dbf20e;p=thirdparty%2Fopenssh-portable.git upstream: Return immediately from get_sock_port if sock <0 so we don't call getsockname on a negative FD. From Coverity CID 291840, ok djm@ OpenBSD-Commit-ID: de1c1130646230c2eda559831fc6bfd1b61d9618 --- diff --git a/canohost.c b/canohost.c index 457e9097e..28f086e5a 100644 --- a/canohost.c +++ b/canohost.c @@ -1,4 +1,4 @@ -/* $OpenBSD: canohost.c,v 1.76 2023/03/03 05:00:34 djm Exp $ */ +/* $OpenBSD: canohost.c,v 1.77 2023/03/31 04:42:29 dtucker Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -163,6 +163,8 @@ get_sock_port(int sock, int local) char strport[NI_MAXSERV]; int r; + if (sock < 0) + return -1; /* Get IP address of client. */ fromlen = sizeof(from); memset(&from, 0, sizeof(from));