From: djm Date: Fri, 3 Mar 2023 05:00:34 +0000 (+0000) Subject: guard against getsockname(-1, ...) from Coverity CID 291832 X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8135c598ee79a5f3e70923204f4687b8debfeb04;p=openbsd guard against getsockname(-1, ...) from Coverity CID 291832 --- diff --git a/usr.bin/ssh/canohost.c b/usr.bin/ssh/canohost.c index 406c5fd32aa..3a7305666ff 100644 --- a/usr.bin/ssh/canohost.c +++ b/usr.bin/ssh/canohost.c @@ -1,4 +1,4 @@ -/* $OpenBSD: canohost.c,v 1.75 2020/10/18 11:32:01 djm Exp $ */ +/* $OpenBSD: canohost.c,v 1.76 2023/03/03 05:00:34 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -44,6 +44,9 @@ get_socket_address(int sock, int remote, int flags) char ntop[NI_MAXHOST]; int r; + if (sock < 0) + return NULL; + /* Get IP address of client. */ addrlen = sizeof(addr); memset(&addr, 0, sizeof(addr));