diff --git a/src/dict.c b/src/dict.c index 75e3a73e..3fce8bd4 100644 --- a/src/dict.c +++ b/src/dict.c @@ -396,8 +396,8 @@ getdns_dict_set_list(struct getdns_dict * dict, char *name, struct getdns_list *newlist; getdns_return_t retval; - if (!dict || !name) - return GETDNS_RETURN_NO_SUCH_DICT_NAME; + if (!dict || !name || !child_list) + return GETDNS_RETURN_INVALID_PARAMETER; retval = getdns_list_copy(child_list, &newlist); if (retval != GETDNS_RETURN_GOOD) @@ -422,7 +422,7 @@ getdns_dict_set_bindata(struct getdns_dict * dict, char *name, struct getdns_bindata *newbindata; if (!dict || !name || !child_bindata) - return GETDNS_RETURN_NO_SUCH_DICT_NAME; + return GETDNS_RETURN_INVALID_PARAMETER; newbindata = getdns_bindata_copy(&dict->mf, child_bindata); if (!newbindata) @@ -446,7 +446,7 @@ getdns_dict_set_int(struct getdns_dict * dict, char *name, struct getdns_dict_item *item; if (!dict || !name) - return GETDNS_RETURN_NO_SUCH_DICT_NAME; + return GETDNS_RETURN_INVALID_PARAMETER; item = getdns_dict_find(dict, name, 1); if (!item) diff --git a/src/list.c b/src/list.c index 5cf7d24e..f71bf5c3 100644 --- a/src/list.c +++ b/src/list.c @@ -59,8 +59,8 @@ getdns_list_get_data_type(struct getdns_list * list, size_t index, return GETDNS_RETURN_NO_SUCH_LIST_ITEM; if (!answer) - return GETDNS_RETURN_WRONG_TYPE_REQUESTED; - + return GETDNS_RETURN_INVALID_PARAMETER; + *answer = list->items[index].dtype; return GETDNS_RETURN_GOOD; } /* getdns_list_get_data_type */ @@ -73,7 +73,10 @@ getdns_list_get_dict(struct getdns_list * list, size_t index, if (!list || index >= list->numinuse) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; - if (!answer || list->items[index].dtype != t_dict) + if (!answer) + return GETDNS_RETURN_INVALID_PARAMETER; + + if (list->items[index].dtype != t_dict) return GETDNS_RETURN_WRONG_TYPE_REQUESTED; *answer = list->items[index].data.dict; @@ -89,7 +92,10 @@ getdns_list_get_list(struct getdns_list * list, size_t index, if (!list || index >= list->numinuse) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; - if (!answer || list->items[index].dtype != t_list) + if (!answer) + return GETDNS_RETURN_INVALID_PARAMETER; + + if (list->items[index].dtype != t_list) return GETDNS_RETURN_WRONG_TYPE_REQUESTED; *answer = list->items[index].data.list; @@ -104,7 +110,10 @@ getdns_list_get_bindata(struct getdns_list * list, size_t index, if (!list || index >= list->numinuse) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; - if (!answer || list->items[index].dtype != t_bindata) + if (!answer) + return GETDNS_RETURN_INVALID_PARAMETER; + + if (list->items[index].dtype != t_bindata) return GETDNS_RETURN_WRONG_TYPE_REQUESTED; *answer = list->items[index].data.bindata; @@ -118,7 +127,10 @@ getdns_list_get_int(struct getdns_list * list, size_t index, uint32_t * answer) if (!list || index >= list->numinuse) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; - if (!answer || list->items[index].dtype != t_int) + if (!answer) + return GETDNS_RETURN_INVALID_PARAMETER; + + if (list->items[index].dtype != t_int) return GETDNS_RETURN_WRONG_TYPE_REQUESTED; *answer = list->items[index].data.n; @@ -332,7 +344,7 @@ getdns_list_add_item(struct getdns_list *list, size_t * index) getdns_return_t retval; if (!list || !index) - return GETDNS_RETURN_NO_SUCH_LIST_ITEM; + return GETDNS_RETURN_INVALID_PARAMETER; if (list->numalloc == list->numinuse) { retval = getdns_list_realloc(list); @@ -355,7 +367,7 @@ getdns_list_set_dict(struct getdns_list * list, size_t index, getdns_return_t retval; if (!list || !child_dict) - return GETDNS_RETURN_NO_SUCH_LIST_ITEM; + return GETDNS_RETURN_INVALID_PARAMETER; if (index > list->numinuse) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; @@ -387,7 +399,7 @@ getdns_list_set_list(struct getdns_list * list, size_t index, getdns_return_t retval; if (!list || !child_list) - return GETDNS_RETURN_NO_SUCH_LIST_ITEM; + return GETDNS_RETURN_INVALID_PARAMETER; if (index > list->numinuse) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; @@ -419,7 +431,7 @@ getdns_list_set_bindata(struct getdns_list * list, size_t index, getdns_return_t retval; if (!list || !child_bindata) - return GETDNS_RETURN_NO_SUCH_LIST_ITEM; + return GETDNS_RETURN_INVALID_PARAMETER; if (index > list->numinuse) return GETDNS_RETURN_NO_SUCH_LIST_ITEM; @@ -450,7 +462,7 @@ getdns_list_set_int(struct getdns_list * list, size_t index, getdns_return_t retval; if (!list) - return GETDNS_RETURN_NO_SUCH_LIST_ITEM; + return GETDNS_RETURN_INVALID_PARAMETER; if (index > list->numinuse) return GETDNS_RETURN_NO_SUCH_LIST_ITEM;