Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check enable_environment for NULL before copying #1624

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion loader/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -2744,7 +2744,8 @@ VkResult loader_read_layer_json(const struct loader_instance *inst, struct loade
cJSON *enable_environment = loader_cJSON_GetObjectItem(layer_node, "enable_environment");

// enable_environment is optional
if (enable_environment && enable_environment->child && enable_environment->child->type == cJSON_String) {
if (enable_environment && enable_environment->child && enable_environment->child->type == cJSON_String &&
enable_environment->child->string && enable_environment->child->valuestring) {
result = loader_copy_to_new_str(inst, enable_environment->child->string, &(props.enable_env_var.name));
if (VK_SUCCESS != result) goto out;
result = loader_copy_to_new_str(inst, enable_environment->child->valuestring, &(props.enable_env_var.value));
Expand Down
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/loader_fuzz_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ TEST(BadJsonInput, ClusterFuzzTestCase_6308459683315712) {
// combine_settings_layers_with_regular_layers
execute_instance_enumerate_fuzzer("clusterfuzz-testcase-instance_enumerate_fuzzer-6308459683315712");
}
TEST(BadJsonInput, ClusterFuzzTestCase_6583684169269248) {
// Crashes ASAN
// Nullptr dereference in loader_copy_to_new_str
execute_instance_enumerate_fuzzer("clusterfuzz-testcase-minimized-instance_enumerate_fuzzer-6583684169269248");
}

TEST(BadJsonInput, ClusterFuzzTestCase_5258042868105216) {
// Doesn't crash with ASAN or UBSAN
// Doesn't reproducibly crash - json_load_fuzzer: Abrt in loader_cJSON_Delete
Expand Down
Loading