Systemd/src/libsystemd-network
Evgeny Vereshchagin 0b75a95ace sd-network: fix memleak in dhcp6_lease_set_domains (#5113)
The simplest way to reproduce:
```diff
diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c
index bd289fa..4e14d8f 100644
--- a/src/libsystemd-network/test-dhcp6-client.c
+++ b/src/libsystemd-network/test-dhcp6-client.c
@@ -286,6 +286,8 @@ static int test_advertise_option(sd_event *e) {
                         assert_se(optlen == 11);
                         assert_se(dhcp6_lease_set_domains(lease, optval,
                                                           optlen) >= 0);
+                        assert_se(dhcp6_lease_set_domains(lease, optval,
+                                                          optlen) >= 0);
                         break;

                 case SD_DHCP6_OPTION_SNTP_SERVERS:
```

Fixes:
```
==27369==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 10 byte(s) in 1 object(s) allocated from:
    #0 0x7f90e7d21160 in strdup (/lib64/libasan.so.3+0x5a160)
    #1 0x7f90e7467f69 in strv_extend src/basic/strv.c:552
    #2 0x5612fcc19379 in dhcp6_option_parse_domainname src/libsystemd-network/dhcp6-option.c:399
    #3 0x5612fcc1acdf in dhcp6_lease_set_domains src/libsystemd-network/sd-dhcp6-lease.c:225
    #4 0x5612fcc06b95 in test_advertise_option src/libsystemd-network/test-dhcp6-client.c:287
    #5 0x5612fcc0a987 in main src/libsystemd-network/test-dhcp6-client.c:761
    #6 0x7f90e6d46400 in __libc_start_main (/lib64/libc.so.6+0x20400)

SUMMARY: AddressSanitizer: 10 byte(s) leaked in 1 allocation(s).
```
2017-01-23 21:12:58 -05:00
..
arp-util.c tree-wide: htonl() is weird, let's use htobe32() instead (#3538) 2016-06-15 01:26:01 +02:00
arp-util.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
dhcp-identifier.c dhcp-identifier: un-inline dhcp_validate_duid_len 2016-05-03 12:09:38 -04:00
dhcp-identifier.h network: get rid of DUID_TYPE_RAW 2016-05-03 12:26:43 -04:00
dhcp-internal.h dhcp: bind udp sockets to interfaces (#4822) 2016-12-07 02:00:05 +01:00
dhcp-lease-internal.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
dhcp-network.c dhcp: bind udp sockets to interfaces (#4822) 2016-12-07 02:00:05 +01:00
dhcp-option.c tree-wide: make ++/-- usage consistent WRT spacing 2016-02-22 20:32:04 -08:00
dhcp-packet.c networkd: support setting dhcp client listen port (#4631) 2016-11-10 18:34:19 -05:00
dhcp-protocol.h dhcp: fix operator precedence issue with macro 2016-05-26 15:34:42 +02:00
dhcp-server-internal.h networkd: Add EmitRouter= option for DHCP Server (#3251) 2016-05-17 19:34:25 -04:00
dhcp6-internal.h sd-dhcp6-client: add log_errno macro and improve debug messages a bit 2016-05-15 19:57:00 -04:00
dhcp6-lease-internal.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
dhcp6-network.c sd-dhcp6-client: bind to link-local address 2015-11-17 14:17:41 +01:00
dhcp6-option.c sd-network: fix memleak in dhcp6_option_parse_domainname (#5114) 2017-01-23 21:11:59 -05:00
dhcp6-protocol.h DHCP DUID, IAID configuration options 2016-03-30 16:33:55 -07:00
icmp6-util.c network: beef up ipv6 RA support considerably 2016-06-06 20:11:38 +02:00
icmp6-util.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
lldp-internal.h lldp: add proper ref counting to sd_lldp object and a separate call for setting the ifindex 2016-06-06 19:59:07 +02:00
lldp-neighbor.c Various fixes for typos found by lintian (#3705) 2016-07-12 12:52:11 +02:00
lldp-neighbor.h lldp: rename TLV accessor pseudo-macros 2016-06-06 19:59:08 +02:00
lldp-network.c tree-wide: htonl() is weird, let's use htobe32() instead (#3538) 2016-06-15 01:26:01 +02:00
lldp-network.h tree-wide: place #pragma once at the same place everywhere 2016-02-20 22:42:29 +01:00
Makefile sd-network: add new library 2014-02-28 01:01:13 +01:00
ndisc-internal.h network: beef up ipv6 RA support considerably 2016-06-06 20:11:38 +02:00
ndisc-router.c ndisc: ignore invalid SLAAC prefix lengths (#4923) 2016-12-20 20:27:06 +01:00
ndisc-router.h network: beef up ipv6 RA support considerably 2016-06-06 20:11:38 +02:00
network-internal.c network: fix const qualifier (#4849) 2016-12-07 16:42:17 -05:00
network-internal.h tree-wide: port more code to use ifname_valid() 2016-05-09 15:45:31 +02:00
sd-dhcp-client.c dhcp: bind udp sockets to interfaces (#4822) 2016-12-07 02:00:05 +01:00
sd-dhcp-lease.c dhcp4: filter bogus DNS/NTP server addresses silently 2016-11-21 22:58:26 +01:00
sd-dhcp-server.c dhcp: bind udp sockets to interfaces (#4822) 2016-12-07 02:00:05 +01:00
sd-dhcp6-client.c tree-wide: use mfree more 2016-10-16 23:35:39 -04:00
sd-dhcp6-lease.c sd-network: fix memleak in dhcp6_lease_set_domains (#5113) 2017-01-23 21:12:58 -05:00
sd-ipv4acd.c tree-wide: use mfree more 2016-10-16 23:35:39 -04:00
sd-ipv4ll.c tree-wide: use mfree more 2016-10-16 23:35:39 -04:00
sd-lldp.c tree-wide: use mfree more 2016-10-16 23:35:39 -04:00
sd-ndisc.c tree-wide: use mfree more 2016-10-16 23:35:39 -04:00
test-acd.c sd-network: rename "index" field of the various clients to "ifindex" 2016-05-26 15:34:42 +02:00
test-dhcp-client.c dhcp: bind udp sockets to interfaces (#4822) 2016-12-07 02:00:05 +01:00
test-dhcp-option.c Merge pull request #2589 from keszybz/resolve-tool-2 2016-02-13 11:15:41 +01:00
test-dhcp-server.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-dhcp6-client.c sd-network: rename "index" field of the various clients to "ifindex" 2016-05-26 15:34:42 +02:00
test-ipv4ll-manual.c sd-network: rename "index" field of the various clients to "ifindex" 2016-05-26 15:34:42 +02:00
test-ipv4ll.c ipv4ll: change "seed" parameter to be uint64_t 2016-05-26 15:34:43 +02:00
test-lldp.c lldp: add proper ref counting to sd_lldp object and a separate call for setting the ifindex 2016-06-06 19:59:07 +02:00
test-ndisc-rs.c network: beef up ipv6 RA support considerably 2016-06-06 20:11:38 +02:00