From 0925fad2014e4910d44bb4d9d9681da4e6962e49 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 6 Jun 2014 23:52:35 +0000 Subject: [PATCH] fix use of %c for ints --- src/gnsrecord/plugin_gnsrecord_dns.c | 43 ++++++++++++++++------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/gnsrecord/plugin_gnsrecord_dns.c b/src/gnsrecord/plugin_gnsrecord_dns.c index 2f14ba5a9..b52dee374 100644 --- a/src/gnsrecord/plugin_gnsrecord_dns.c +++ b/src/gnsrecord/plugin_gnsrecord_dns.c @@ -239,10 +239,10 @@ dns_value_to_string (void *cls, return NULL; /* malformed */ tlsa = data; if (0 == GNUNET_asprintf (&tlsa_str, - "%c %c %c %s", - tlsa->usage, - tlsa->selector, - tlsa->matching_type, + "%u %u %u %s", + (unsigned int) tlsa->usage, + (unsigned int) tlsa->selector, + (unsigned int) tlsa->matching_type, (const char *) &tlsa[1])) { GNUNET_free (tlsa_str); @@ -599,22 +599,29 @@ dns_string_to_value (void *cls, memcpy (*data, &value_aaaa, sizeof (value_aaaa)); return GNUNET_OK; case GNUNET_DNSPARSER_TYPE_TLSA: - *data_size = sizeof (struct GNUNET_TUN_DnsTlsaRecord) + strlen (s) - 6; - *data = tlsa = GNUNET_malloc (*data_size); - if (4 != SSCANF (s, "%c %c %c %s", - &tlsa->usage, - &tlsa->selector, - &tlsa->matching_type, - (char*)&tlsa[1])) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Unable to parse TLSA record string `%s'\n"), - s); - *data_size = 0; - GNUNET_free (tlsa); - return GNUNET_SYSERR; + unsigned int usage; + unsigned int selector; + unsigned int matching_type; + + *data_size = sizeof (struct GNUNET_TUN_DnsTlsaRecord) + strlen (s) - 6; + *data = tlsa = GNUNET_malloc (*data_size); + if (4 != SSCANF (s, + "%u %u %u %s", + (char*)&tlsa[1])) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Unable to parse TLSA record string `%s'\n"), + s); + *data_size = 0; + GNUNET_free (tlsa); + return GNUNET_SYSERR; + } + tlsa->usage = (uint8_t) usage; + tlsa->selector = (uint8_t) selector; + tlsa->matching_type = (uint8_t) matching_type; + return GNUNET_OK; } - return GNUNET_OK; default: return GNUNET_SYSERR; } -- 2.25.1