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

Function nvpair_unpack_string

freebsd/contrib/libnv/bsd_nvpair.c:774–800  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

772}
773
774const unsigned char *
775nvpair_unpack_string(bool isbe __unused, nvpair_t *nvp,
776 const unsigned char *ptr, size_t *leftp)
777{
778
779 PJDLOG_ASSERT(nvp->nvp_type == NV_TYPE_STRING);
780
781 if (*leftp < nvp->nvp_datasize || nvp->nvp_datasize == 0) {
782 ERRNO_SET(EINVAL);
783 return (NULL);
784 }
785
786 if (strnlen((const char *)ptr, nvp->nvp_datasize) !=
787 nvp->nvp_datasize - 1) {
788 ERRNO_SET(EINVAL);
789 return (NULL);
790 }
791
792 nvp->nvp_data = (uint64_t)(uintptr_t)nv_strdup((const char *)ptr);
793 if (nvp->nvp_data == 0)
794 return (NULL);
795
796 ptr += nvp->nvp_datasize;
797 *leftp -= nvp->nvp_datasize;
798
799 return (ptr);
800}
801
802const unsigned char *
803nvpair_unpack_nvlist(bool isbe __unused, nvpair_t *nvp,

Callers 1

nvlist_xunpackFunction · 0.85

Calls 1

strnlenFunction · 0.85

Tested by

no test coverage detected