]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared: make dns_packet_read_uint{8,32} accept NULL ret 41426/head
authorMichael Vogt <michael@amutable.com>
Tue, 31 Mar 2026 15:40:03 +0000 (17:40 +0200)
committerMichael Vogt <michael@amutable.com>
Tue, 31 Mar 2026 16:30:40 +0000 (18:30 +0200)
The shared/ dns_packet_read_uint*() functions used to be a bit
inconsistent when it comes to the handling of NULL in *ret. The
helpers dns_packet_read_{uint16,name} accepted NULL but the
dns_packet_read_uint{8,32} did not.

This commit makes them all symmetric in accepting NULL.

src/shared/dns-packet.c

index 70844c22f7cb208bf1f4a4ecc79a78d07c872ac5..f8078c1211206c76de4882ed65bd621fa770993f 100644 (file)
@@ -1468,13 +1468,14 @@ int dns_packet_read_uint8(DnsPacket *p, uint8_t *ret, size_t *start) {
         int r;
 
         assert(p);
-        assert(ret);
 
         r = dns_packet_read(p, sizeof(uint8_t), &d, start);
         if (r < 0)
                 return r;
 
-        *ret = ((uint8_t*) d)[0];
+        if (ret)
+                *ret = ((uint8_t*) d)[0];
+
         return 0;
 }
 
@@ -1499,13 +1500,13 @@ int dns_packet_read_uint32(DnsPacket *p, uint32_t *ret, size_t *start) {
         int r;
 
         assert(p);
-        assert(ret);
 
         r = dns_packet_read(p, sizeof(uint32_t), &d, start);
         if (r < 0)
                 return r;
 
-        *ret = unaligned_read_be32(d);
+        if (ret)
+                *ret = unaligned_read_be32(d);
 
         return 0;
 }