if the socket is connected, we can use recv() instead of recvfrom()
authorderaadt <deraadt@openbsd.org>
Wed, 24 Aug 2022 01:32:21 +0000 (01:32 +0000)
committerderaadt <deraadt@openbsd.org>
Wed, 24 Aug 2022 01:32:21 +0000 (01:32 +0000)
ok jmatthew

lib/libc/rpc/clnt_udp.c

index 190d3ae..e40347b 100644 (file)
@@ -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)