Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F106075465
D1880.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D1880.diff
View Options
Index: head/lib/libnv/nvpair.c
===================================================================
--- head/lib/libnv/nvpair.c
+++ head/lib/libnv/nvpair.c
@@ -1128,6 +1128,12 @@
return (NULL);
}
+ if (nvlist_error(value) != 0) {
+ errno = nvlist_error(value);
+ nvlist_destroy(value);
+ return (NULL);
+ }
+
nvp = nvpair_allocv(NV_TYPE_NVLIST, (uint64_t)(uintptr_t)value, 0,
namefmt, nameap);
if (nvp == NULL)
Index: head/lib/libnv/tests/nv_tests.cc
===================================================================
--- head/lib/libnv/tests/nv_tests.cc
+++ head/lib/libnv/tests/nv_tests.cc
@@ -243,6 +243,22 @@
nvlist_destroy(nvl);
}
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_add_nvlist__child_with_error);
+ATF_TEST_CASE_BODY(nvlist_add_nvlist__child_with_error)
+{
+ nvlist_t *nvl, *parent;
+
+ nvl = nvlist_create(0);
+ parent = nvlist_create(0);
+
+ nvlist_set_error(nvl, EBADF);
+ nvlist_add_nvlist(parent, "test", nvl);
+ ATF_REQUIRE_EQ(nvlist_error(parent), EBADF);
+
+ nvlist_destroy(nvl);
+ nvlist_destroy(parent);
+}
+
ATF_TEST_CASE_WITHOUT_HEAD(nvlist_add_binary__single_insert);
ATF_TEST_CASE_BODY(nvlist_add_binary__single_insert)
{
@@ -654,6 +670,21 @@
nvlist_destroy(parent);
}
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_move_nvlist__child_with_error);
+ATF_TEST_CASE_BODY(nvlist_move_nvlist__child_with_error)
+{
+ nvlist_t *nvl, *parent;
+
+ nvl = nvlist_create(0);
+ parent = nvlist_create(0);
+
+ nvlist_set_error(nvl, EBADF);
+ nvlist_move_nvlist(parent, "test", nvl);
+ ATF_REQUIRE_EQ(nvlist_error(parent), EBADF);
+
+ nvlist_destroy(parent);
+}
+
ATF_TEST_CASE_WITHOUT_HEAD(nvlist_move_nvlist__single_insert);
ATF_TEST_CASE_BODY(nvlist_move_nvlist__single_insert)
{
@@ -1177,6 +1208,7 @@
ATF_ADD_TEST_CASE(tp, nvlist_add_number__single_insert);
ATF_ADD_TEST_CASE(tp, nvlist_add_string__single_insert);
ATF_ADD_TEST_CASE(tp, nvlist_add_nvlist__single_insert);
+ ATF_ADD_TEST_CASE(tp, nvlist_add_nvlist__child_with_error);
ATF_ADD_TEST_CASE(tp, nvlist_add_binary__single_insert);
ATF_ADD_TEST_CASE(tp, nvlist_clone__empty_nvlist);
@@ -1192,6 +1224,7 @@
ATF_ADD_TEST_CASE(tp, nvlist_move_string__single_insert);
ATF_ADD_TEST_CASE(tp, nvlist_move_nvlist__single_insert);
ATF_ADD_TEST_CASE(tp, nvlist_move_nvlist__null_child);
+ ATF_ADD_TEST_CASE(tp, nvlist_move_nvlist__child_with_error);
ATF_ADD_TEST_CASE(tp, nvlist_move_binary__single_insert);
ATF_ADD_TEST_CASE(tp, nvlist_take_bool__single_remove);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 25, 11:48 PM (11 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15599643
Default Alt Text
D1880.diff (2 KB)
Attached To
Mode
D1880: Prevent creation of an invalid nvlist
Attached
Detach File
Event Timeline
Log In to Comment