From 4d6da4457a80fc2cea4d0e3a1f332107a28b067d Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 15 Dec 2021 16:55:57 +0000 Subject: [PATCH] gthreadedresolver: Tighten up types and constness of parsing code Not everything should be an int. This code is quite dated. We now try to use `guint8*` to represent arbitrary binary data, rather than `guchar*` (which makes it sound like some form of string). Signed-off-by: Philip Withnall --- gio/gthreadedresolver.c | 40 ++++++++++++++++++++-------------------- gio/gthreadedresolver.h | 4 ++-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/gio/gthreadedresolver.c b/gio/gthreadedresolver.c index 1a339ecf1..48545d6ad 100644 --- a/gio/gthreadedresolver.c +++ b/gio/gthreadedresolver.c @@ -530,9 +530,9 @@ typedef enum __ns_type { #endif /* __BIONIC__ */ static GVariant * -parse_res_srv (guchar *answer, - guchar *end, - guchar **p) +parse_res_srv (const guint8 *answer, + const guint8 *end, + const guint8 **p) { gchar namebuf[1024]; guint16 priority, weight, port; @@ -550,9 +550,9 @@ parse_res_srv (guchar *answer, } static GVariant * -parse_res_soa (guchar *answer, - guchar *end, - guchar **p) +parse_res_soa (const guint8 *answer, + const guint8 *end, + const guint8 **p) { gchar mnamebuf[1024]; gchar rnamebuf[1024]; @@ -578,9 +578,9 @@ parse_res_soa (guchar *answer, } static GVariant * -parse_res_ns (guchar *answer, - guchar *end, - guchar **p) +parse_res_ns (const guint8 *answer, + const guint8 *end, + const guint8 **p) { gchar namebuf[1024]; @@ -590,9 +590,9 @@ parse_res_ns (guchar *answer, } static GVariant * -parse_res_mx (guchar *answer, - guchar *end, - guchar **p) +parse_res_mx (const guint8 *answer, + const guint8 *end, + const guint8 **p) { gchar namebuf[1024]; guint16 preference; @@ -607,13 +607,13 @@ parse_res_mx (guchar *answer, } static GVariant * -parse_res_txt (guchar *answer, - guchar *end, - guchar **p) +parse_res_txt (const guint8 *answer, + const guint8 *end, + const guint8 **p) { GVariant *record; GPtrArray *array; - guchar *at = *p; + const guint8 *at = *p; gsize len; array = g_ptr_array_new_with_free_func (g_free); @@ -655,16 +655,16 @@ g_resolver_record_type_to_rrtype (GResolverRecordType type) GList * g_resolver_records_from_res_query (const gchar *rrname, gint rrtype, - guchar *answer, - gint len, + const guint8 *answer, + gssize len, gint herr, GError **error) { gint count; gchar namebuf[1024]; - guchar *end, *p; + const guint8 *end, *p; guint16 type, qclass, rdlength; - HEADER *header; + const HEADER *header; GList *records; GVariant *record; diff --git a/gio/gthreadedresolver.h b/gio/gthreadedresolver.h index 9b0f98222..95a5fe55f 100644 --- a/gio/gthreadedresolver.h +++ b/gio/gthreadedresolver.h @@ -46,8 +46,8 @@ GType g_threaded_resolver_get_type (void) G_GNUC_CONST; GLIB_AVAILABLE_IN_ALL GList *g_resolver_records_from_res_query (const gchar *rrname, gint rrtype, - guchar *answer, - gint len, + const guint8 *answer, + gssize len, gint herr, GError **error);