Commit a18c1ae0 authored by Pekka Pessi's avatar Pekka Pessi

Improved argument checking in sresolv.

darcs-hash:20051223130532-65a35-6f1e6a38dff05126d8afdd0f3c12f8efacd13bef.gz
parent 6571dfbb
This diff is collapsed.
......@@ -31,7 +31,6 @@
* @author Teemu Jalava <Teemu.Jalava@nokia.com>,
* @author Mikko Haataja <ext-Mikko.A.Haataja@nokia.com>.
*
* @date Last modified: Fri Sep 9 10:56:31 2005 ppessi
*/
#include <su.h>
......@@ -129,7 +128,7 @@ struct sres_a6_record
uint8_t a6_prelen;
uint8_t a6_pad[3];
struct in6_addr a6_suffix;
char *a6_prename;
char *a6_prename;
};
/** Address record for IPv6 (RFC 1886). */
......@@ -312,7 +311,7 @@ sres_record_t **sres_cached_answers_sockaddr(sres_resolver_t *res,
struct sockaddr const *addr);
/** Sort the list of records */
void sres_sort_answers(sres_resolver_t *res, sres_record_t **answers);
int sres_sort_answers(sres_resolver_t *res, sres_record_t **answers);
/** Sort and filter the list of records */
int sres_filter_answers(sres_resolver_t *sres, sres_record_t **answers,
......@@ -341,7 +340,7 @@ sres_resolver_t *sres_resolver_create(su_root_t *root,
char const *resolv_conf,
tag_type_t, tag_value_t, ...);
/** Destroy a resolver object. */
void sres_resolver_destroy(sres_resolver_t *res);
int sres_resolver_destroy(sres_resolver_t *res);
/* Return socket used by root */
int sres_resolver_root_socket(sres_resolver_t *res);
......
......@@ -1668,14 +1668,14 @@ int test_api_errors(sres_context_t *noctx)
s = sockets[0];
TEST(sres_resolver_ref(NULL), NULL);
TEST(errno, EINVAL);
TEST(errno, EFAULT);
sres_resolver_unref(NULL);
TEST(sres_resolver_add_mutex(NULL, NULL, NULL, NULL), -1);
TEST(errno, EINVAL);
TEST(errno, EFAULT);
TEST(sres_resolver_set_userdata(NULL, NULL), NULL);
TEST(errno, EINVAL);
TEST(errno, EFAULT);
TEST(sres_resolver_get_userdata(NULL), NULL);
......@@ -1688,31 +1688,44 @@ int test_api_errors(sres_context_t *noctx)
#if HAVE_SU_WAIT_H
errno = 0;
TEST(sres_resolver_root_socket(res), -1); TEST(errno, EINVAL); errno = 0;
TEST(sres_resolver_create(NULL, NULL, TAG_END()), NULL);
TEST(errno, EFAULT); errno = 0;
TEST(sres_resolver_root_socket(NULL), -1);
TEST(errno, EFAULT); errno = 0;
TEST(sres_query(NULL, test_answer, ctx, sres_type_a, "example.com"), NULL);
TEST(errno, EFAULT); errno = 0;
TEST(sres_query_sockaddr(NULL, test_answer, ctx, sres_qtype_any, sa), NULL);
TEST(errno, EFAULT); errno = 0;
TEST(sres_resolver_destroy(NULL), -1);
TEST(errno, EFAULT); errno = 0;
TEST(sres_resolver_root_socket(res), -1);
TEST(errno, EINVAL); errno = 0;
TEST(sres_query(res, test_answer, ctx, sres_type_a, "example.com"), NULL);
TEST(errno, EINVAL); errno = 0;
TEST(sres_query_sockaddr(res, test_answer, ctx, sres_qtype_any, sa), NULL);
TEST(errno, EINVAL); errno = 0;
sres_resolver_destroy(res);
TEST(sres_resolver_create(NULL, NULL, TAG_END()), NULL);
sres_resolver_destroy(NULL);
TEST(sres_resolver_destroy(res), -1); /* res should be alive after this! */
TEST(errno, EINVAL); errno = 0;
#endif
errno = 0;
TEST(sres_query_make(NULL, test_answer, ctx, s, sres_type_a, "com"), NULL);
TEST(errno, EINVAL);
TEST(errno, EFAULT); errno = 0;
TEST(sres_query_make(res, test_answer, ctx, s, sres_type_a, NULL), NULL);
TEST(errno, EINVAL);
TEST(errno, EFAULT); errno = 0;
TEST(sres_query_make_sockaddr(res, test_answer, ctx, s,
sres_qtype_any, sa),
NULL);
sres_qtype_any, sa), NULL);
TEST(errno, EAFNOSUPPORT); errno = 0;
TEST(sres_cached_answers(NULL, sres_qtype_any, "example.com"), NULL);
TEST(errno, EFAULT); errno = 0;
TEST(sres_cached_answers(res, sres_qtype_any, NULL), NULL);
TEST(errno, EFAULT); errno = 0;
TEST(sres_cached_answers(res, sres_qtype_any, name2048), NULL);
TEST(errno, ENAMETOOLONG); errno = 0;
TEST(sres_cached_answers_sockaddr(res, sres_qtype_any, sa), NULL);
TEST(errno, EAFNOSUPPORT); errno = 0;
sres_free_answer(res, NULL);
sres_free_answers(res, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment