From f5430a3ef308f3a102899fcaf7fbece757082f2a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 23 Jul 2015 04:04:19 +0200 Subject: resolve: unify memdup() code when parsing RRs Let's make dns_packet_read_public_key() more generic by renaming it to dns_packet_read_memdup() (which more accurately describes what it does...). Then, patch all cases where we memdup() RR data to use this new call. This specifically checks for zero-length objects, and handles them gracefully. It will set zero length payload fields as a result. Special care should be taken to ensure that any code using this call can handle the returned allocated field to be NULL if the size is specified as 0! --- src/resolve/resolved-dns-rr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/resolve/resolved-dns-rr.h') diff --git a/src/resolve/resolved-dns-rr.h b/src/resolve/resolved-dns-rr.h index bdd5a5c824..dc51126f97 100644 --- a/src/resolve/resolved-dns-rr.h +++ b/src/resolve/resolved-dns-rr.h @@ -53,7 +53,7 @@ struct DnsResourceRecord { union { struct { void *data; - uint16_t size; + size_t size; } generic; struct { -- cgit v1.2.3-54-g00ecf