Issues from unit tests

This commit is contained in:
Willem Toorop 2017-09-22 11:12:27 +02:00
parent da2aa634d3
commit a3bfee7d0a
5 changed files with 34 additions and 49 deletions

View File

@ -84,7 +84,7 @@ install: getdns.pc getdns_ext_event.pc install-lib @INSTALL_GETDNS_QUERY@
@echo "***"
@echo "*** - will be preferred and used for DNSSEC validation, however"
@echo "*** getdns will fallback to trust-anchors obtained via built-in"
@evho "*** trust anchor management when the anchors from the default"
@echo "*** trust anchor management when the anchors from the default"
@echo "*** location fail to validate the root DNSKEY rrset."
@echo "***"
@echo "*** To prevent expired DNSSEC trust anchors to be used for"

View File

@ -3635,9 +3635,9 @@ _getdns_context_prepare_for_resolution(struct getdns_context *context,
char *
_getdns_strdup(const struct mem_funcs *mfs, const char *s)
{
size_t sz = strlen(s) + 1;
size_t sz;
char *r;
if (!s || !(r = GETDNS_XMALLOC(*mfs, char, sz)))
if (!s || !(r = GETDNS_XMALLOC(*mfs, char, (sz = strlen(s) + 1))))
return NULL;
else
return memcpy(r, s, sz);

View File

@ -1827,6 +1827,12 @@ getdns_yaml2dict(const char *str, getdns_dict **dict)
#endif /* USE_YAML_CONFIG */
}
/* WT: I am not certain about the value of yaml2list...
* I don't see how yaml2bindata and yaml2int would be different from
* the str2bindata and str2int ones.
*/
#if 0
getdns_return_t
getdns_yaml2list(const char *str, getdns_list **list)
{
@ -1851,10 +1857,6 @@ getdns_yaml2list(const char *str, getdns_list **list)
#endif /* USE_YAML_CONFIG */
}
/* WT: I don't see how the two functions below would be different from
* the str2bindata and str2int ones.
*/
#if 0
getdns_return_t
getdns_yaml2bindata(const char *str, getdns_bindata **bindata)
{

View File

@ -1655,6 +1655,28 @@ getdns_msg_dict2str_scan(
* @{
*/
/**
* Convert YAML text to a getdns_dict.
*
* @param str A textual representation of a getdns_dict.
* The format is similar, but not precisely YAML.
* - When str contains an IP or IPv6 address, it is converted
* to an getdns dict representation of that address. This may contain
* a port, tls_port, tsig spec or tls authentication name in the same
* way as may be given with the `getdns_query` tool. For example:
* `185.49.140.67:80#443` will result in the following getdns_dict:
*
* { address_type: "IPv4"
* , address_data: "185.49.140.67"
* , port: 80
* , tls_port: 443
* }
* @param dict The returned getdns_dict.
* @return GETDNS_RETURN_GOOD on success or an error code on failure.
*/
getdns_return_t
getdns_yaml2dict(const char *str, getdns_dict **dict);
/**
* Convert string text to a getdns_dict.
*
@ -1744,45 +1766,6 @@ getdns_str2bindata(const char *str, getdns_bindata **bindata);
getdns_return_t
getdns_str2int(const char *str, uint32_t *value);
/** @}
*/
/**
* \defgroup Uyaml2getdns_data Converting YAML input to getdns data structures
* @{
*/
/**
* Convert YAML text to a getdns_dict.
*
* @param str A textual representation of a getdns_dict.
* The format is similar, but not precisely YAML.
* - When str contains an IP or IPv6 address, it is converted
* to an getdns dict representation of that address. This may contain
* a port, tls_port, tsig spec or tls authentication name in the same
* way as may be given with the `getdns_query` tool. For example:
* `185.49.140.67:80#443` will result in the following getdns_dict:
*
* { address_type: "IPv4"
* , address_data: "185.49.140.67"
* , port: 80
* , tls_port: 443
* }
* @param dict The returned getdns_dict.
* @return GETDNS_RETURN_GOOD on success or an error code on failure.
*/
getdns_return_t
getdns_yaml2dict(const char *str, getdns_dict **dict);
/**
* Convert YAML text to a getdns_list.
*
* @param str A textual representation of a getdns_list.
* @param list The returned getdns_list.
* @return GETDNS_RETURN_GOOD on success or an error code on failure.
*/
getdns_return_t
getdns_yaml2list(const char *str, getdns_list **list);
/** @}
*/

View File

@ -56,7 +56,7 @@ int main(int ac, char *av[])
goto fail;
}
r = getdns_yaml2list("[\"One\", \"two\", \"three\"]", &list);
r = getdns_str2list("[\"One\", \"two\", \"three\"]", &list);
if (r) {
fprintf(stderr, "Error setting list data: %s", getdns_get_errorstr_by_id(r));
goto fail;
@ -68,7 +68,7 @@ int main(int ac, char *av[])
goto fail;
}
r = getdns_yaml2bindata("2001:7fd::1", &bindata);
r = getdns_str2bindata("2001:7fd::1", &bindata);
if (r) {
fprintf(stderr, "Error setting bindata: %s", getdns_get_errorstr_by_id(r));
goto fail;
@ -81,7 +81,7 @@ int main(int ac, char *av[])
}
uint32_t intval;
r = getdns_yaml2int("32767", &intval);
r = getdns_str2int("32767", &intval);
if (r) {
fprintf(stderr, "Error setting int: %s", getdns_get_errorstr_by_id(r));
goto fail;