MCPcopy Create free account
hub / github.com/F-Stack/f-stack / nvlist_unpack_header

Function nvlist_unpack_header

freebsd/contrib/libnv/nvlist.c:1077–1116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1075}
1076
1077const unsigned char *
1078nvlist_unpack_header(nvlist_t *nvl, const unsigned char *ptr, size_t nfds,
1079 bool *isbep, size_t *leftp)
1080{
1081 struct nvlist_header nvlhdr;
1082 int inarrayf;
1083
1084 if (*leftp < sizeof(nvlhdr))
1085 goto fail;
1086
1087 memcpy(&nvlhdr, ptr, sizeof(nvlhdr));
1088
1089 if (!nvlist_check_header(&nvlhdr))
1090 goto fail;
1091
1092 if (nvlhdr.nvlh_size != *leftp - sizeof(nvlhdr))
1093 goto fail;
1094
1095 /*
1096 * nvlh_descriptors might be smaller than nfds in embedded nvlists.
1097 */
1098 if (nvlhdr.nvlh_descriptors > nfds)
1099 goto fail;
1100
1101 if ((nvlhdr.nvlh_flags & ~NV_FLAG_ALL_MASK) != 0)
1102 goto fail;
1103
1104 inarrayf = (nvl->nvl_flags & NV_FLAG_IN_ARRAY);
1105 nvl->nvl_flags = (nvlhdr.nvlh_flags & NV_FLAG_PUBLIC_MASK) | inarrayf;
1106
1107 ptr += sizeof(nvlhdr);
1108 if (isbep != NULL)
1109 *isbep = (((int)nvlhdr.nvlh_flags & NV_FLAG_BIG_ENDIAN) != 0);
1110 *leftp -= sizeof(nvlhdr);
1111
1112 return (ptr);
1113fail:
1114 ERRNO_SET(EINVAL);
1115 return (NULL);
1116}
1117
1118static nvlist_t *
1119nvlist_xunpack(const void *buf, size_t size, const int *fds, size_t nfds,

Callers 2

nvlist_xunpackFunction · 0.85
nvpair_unpack_nvlistFunction · 0.85

Calls 2

nvlist_check_headerFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected