From: Aaron Hurt Date: Tue, 4 Aug 2015 16:13:13 +0000 (-0500) Subject: added NULL checks X-Git-Tag: release_3_0_10~261^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1180%2Fhead;p=thirdparty%2Ffreeradius-server.git added NULL checks --- diff --git a/src/modules/rlm_couchbase/jsonc_missing.c b/src/modules/rlm_couchbase/jsonc_missing.c index 183302279d3..dc3e7f6ca21 100644 --- a/src/modules/rlm_couchbase/jsonc_missing.c +++ b/src/modules/rlm_couchbase/jsonc_missing.c @@ -38,7 +38,7 @@ RCSID("$Id$") #ifndef HAVE_JSON_OBJECT_GET_STRING_LEN int json_object_get_string_len(json_object *obj) { - if (json_object_get_type(obj) != json_type_string) + if ((obj == NULL) || (json_object_get_type(obj) != json_type_string)) return 0; return (int)strlen(json_object_get_string(obj)); } diff --git a/src/modules/rlm_couchbase/mod.c b/src/modules/rlm_couchbase/mod.c index 9e1e6197e0c..c5b721df647 100644 --- a/src/modules/rlm_couchbase/mod.c +++ b/src/modules/rlm_couchbase/mod.c @@ -264,7 +264,7 @@ void *mod_json_object_to_value_pairs(json_object *json, const char *section, REQ /* get config payload */ if (json_object_object_get_ex(json, section, &jobj)) { /* make sure we have the correct type */ - if (!json_object_is_type(jobj, json_type_object)) { + if ((jobj == NULL) || !json_object_is_type(jobj, json_type_object)) { /* log error */ RERROR("invalid json type for '%s' section - sections must be json objects", section); /* reuturn */ @@ -273,7 +273,7 @@ void *mod_json_object_to_value_pairs(json_object *json, const char *section, REQ /* loop through object */ json_object_object_foreach(jobj, attribute, json_vp) { /* check for appropriate type in value and op */ - if (!json_object_is_type(json_vp, json_type_object)) { + if ((jobj == NULL) || !json_object_is_type(json_vp, json_type_object)) { /* log error */ RERROR("invalid json type for '%s' attribute - attributes must be json objects", attribute); @@ -286,6 +286,8 @@ void *mod_json_object_to_value_pairs(json_object *json, const char *section, REQ /* create pair from json object */ if (json_object_object_get_ex(json_vp, "value", &jval) && json_object_object_get_ex(json_vp, "op", &jop)) { + /* check for null before getting type */ + if (jval == NULL) return NULL; /* make correct pairs based on json object type */ switch (json_object_get_type(jval)) { case json_type_double: @@ -617,7 +619,7 @@ int mod_load_client_documents(rlm_couchbase_t *inst, CONF_SECTION *tmpl, CONF_SE DEBUG3("rlm_couchbase: jrows == %s", json_object_to_json_string(jrows)); /* check for valid row value */ - if (!json_object_is_type(jrows, json_type_array) || json_object_array_length(jrows) < 1) { + if ((jrows == NULL) || !json_object_is_type(jrows, json_type_array) || json_object_array_length(jrows) < 1) { /* log error */ ERROR("rlm_couchbase: no valid rows returned from view: %s", vpath); /* set return */