Page MenuHomeFreeBSD

D32722.id97644.diff
No OneTemporary

D32722.id97644.diff

Index: sys/contrib/libnv/nvlist.c
===================================================================
--- sys/contrib/libnv/nvlist.c
+++ sys/contrib/libnv/nvlist.c
@@ -1277,10 +1277,16 @@
struct nvlist_header nvlhdr;
nvlist_t *nvl, *ret;
unsigned char *buf;
- size_t nfds, size, i;
- int *fds;
+ size_t nfds, size, i, offset;
+ int *fds, soflags, sotype;
+ socklen_t solen;
+
+ solen = sizeof(sotype);
+ if (getsockopt(sock, SOL_SOCKET, SO_TYPE, &sotype, &solen) != 0)
+ return (NULL);
- if (buf_recv(sock, &nvlhdr, sizeof(nvlhdr), 0) == -1)
+ soflags = sotype == SOCK_DGRAM ? MSG_PEEK : 0;
+ if (buf_recv(sock, &nvlhdr, sizeof(nvlhdr), soflags) == -1)
return (NULL);
if (!nvlist_check_header(&nvlhdr))
@@ -1293,12 +1299,17 @@
if (buf == NULL)
return (NULL);
- memcpy(buf, &nvlhdr, sizeof(nvlhdr));
-
ret = NULL;
fds = NULL;
- if (buf_recv(sock, buf + sizeof(nvlhdr), size - sizeof(nvlhdr), 0) == -1)
+ if (sotype == SOCK_DGRAM)
+ offset = 0;
+ else {
+ memcpy(buf, &nvlhdr, sizeof(nvlhdr));
+ offset = sizeof(nvlhdr);
+ }
+
+ if (buf_recv(sock, buf + offset, size - offset, 0) == -1)
goto out;
if (nfds > 0) {

File Metadata

Mime Type
text/plain
Expires
Tue, Oct 13, 1:13 AM (3 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40714900
Default Alt Text
D32722.id97644.diff (1 KB)

Event Timeline