From c1053578965866fc88cbd7618d0a63df19bdd0a1 Mon Sep 17 00:00:00 2001 From: dtucker Date: Fri, 31 Mar 2023 04:42:29 +0000 Subject: [PATCH] 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@ --- usr.bin/ssh/canohost.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.bin/ssh/canohost.c b/usr.bin/ssh/canohost.c index 3a7305666ff..bb7ab4de4a3 100644 --- a/usr.bin/ssh/canohost.c +++ b/usr.bin/ssh/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 @@ -129,6 +129,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)); -- 2.20.1