This commit fixes the incorrect dereferencing of pointers when
retrieving data from the name/version members of the pkg_info
structure in the isu_pkg_get_name/isu_pkg_get_version functions
of the libisu public API.
Although a situation where an instance of the pkg_info structure is
correctly allocated, but its name/version components are NULL, should
not occur during normal usage, public functions must be resilient to
such malformed arguments and respond with an appropriate error rather
than a segfault.
Change-Id: I641b003568a0db79eab79f192c2f612bb6900721
struct _isu_pkg_info* pkg_info_i = (struct _isu_pkg_info*)pkg_info;
+ if (pkg_info_i->name == NULL) {
+ return ISU_RES_ERR_INTERNAL;
+ }
+
if (len < strlen(pkg_info_i->name)) {
return ISU_RES_ERR_BUFF_TOO_SMALL;
}
struct _isu_pkg_info* pkg_info_i = (struct _isu_pkg_info*)pkg_info;
+ if (pkg_info_i->version == NULL) {
+ return ISU_RES_ERR_INTERNAL;
+ }
+
if (len < strlen(pkg_info_i->version)) {
return ISU_RES_ERR_BUFF_TOO_SMALL;
}