]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/resolve/resolved-dns-rr.c
resolve: unify memdup() code when parsing RRs 669/head
authorLennart Poettering <lennart@poettering.net>
Thu, 23 Jul 2015 02:04:19 +0000 (04:04 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 23 Jul 2015 02:50:19 +0000 (04:50 +0200)
commitf5430a3ef308f3a102899fcaf7fbece757082f2a
treeca31992b7c4fff12ebcf2ec4f254a2b964b0ccd6
parent6aafa9483d167f55a50e01f4dc5984866f12c8ec
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-packet.c
src/resolve/resolved-dns-rr.c
src/resolve/resolved-dns-rr.h