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
This commit is contained in:
dtucker@openbsd.org 2023-03-31 04:42:29 +00:00 committed by Darren Tucker
parent 1c1124dc90
commit 6f0308a3e7
No known key found for this signature in database
1 changed files with 3 additions and 1 deletions

View File

@ -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 <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, 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));