Skip to content

Commit 6def797

Browse files
committed
reader: check type of properties in jgf
Problem: the JGF reader requires each vertex's 'properties' field to be either null or a JSON object, but doesn't ever check the type. This leads to silent failures when the type read in is wrong. Add a check for the type of the properties field if it is not null.
1 parent 68c636a commit 6def797

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

resource/readers/resource_reader_jgf.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,13 @@ int resource_reader_jgf_t::fill_fetcher (json_t *element, fetch_helper_t &f,
401401
}
402402
*properties = json_object_get (metadata, "properties");
403403
*paths = p;
404+
if (*properties && !json_is_object (*properties)) {
405+
errno = EINVAL;
406+
m_err_msg += __FUNCTION__;
407+
m_err_msg += ": key (properties) must be an object or null for ";
408+
m_err_msg += std::string (f.vertex_id) + ".\n";
409+
goto done;
410+
}
404411
rc = 0;
405412
done:
406413
return rc;

0 commit comments

Comments
 (0)