Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F175612138
D32722.id97644.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D32722.id97644.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D32722: libnv: read entire datagram in nvlist_recv()
Attached
Detach File
Event Timeline
Log In to Comment