From 482918d2d2bc6637d8726888923fd59c1e927139 Mon Sep 17 00:00:00 2001 From: deraadt Date: Wed, 24 Aug 2022 01:32:21 +0000 Subject: [PATCH] if the socket is connected, we can use recv() instead of recvfrom() ok jmatthew --- lib/libc/rpc/clnt_udp.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/libc/rpc/clnt_udp.c b/lib/libc/rpc/clnt_udp.c index 190d3aeafc5..e40347be5c7 100644 --- a/lib/libc/rpc/clnt_udp.c +++ b/lib/libc/rpc/clnt_udp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clnt_udp.c,v 1.39 2022/07/15 17:33:28 deraadt Exp $ */ +/* $OpenBSD: clnt_udp.c,v 1.40 2022/08/24 01:32:21 deraadt Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -303,9 +303,15 @@ send_again: do { fromlen = sizeof(struct sockaddr); - inlen = recvfrom(cu->cu_sock, cu->cu_inbuf, - (int) cu->cu_recvsz, 0, - (struct sockaddr *)&from, &fromlen); + if (cu->cu_connected) { + inlen = recv(cu->cu_sock, cu->cu_inbuf, + (int) cu->cu_recvsz, 0); + } else { + + inlen = recvfrom(cu->cu_sock, cu->cu_inbuf, + (int) cu->cu_recvsz, 0, + (struct sockaddr *)&from, &fromlen); + } } while (inlen == -1 && errno == EINTR); if (inlen == -1) { if (errno == EWOULDBLOCK) -- 2.20.1