diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2015-08-07 11:17:03 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2015-10-02 17:39:22 +0200 |
commit | 564cabd46c7c1532ad4d562bf8332eaed49ac201 (patch) | |
tree | 100e3fabf2b132259456f0c83aaf8b39393a3bd8 /src | |
parent | d8c89d6198651e34786bc78df26f313eede9918b (diff) | |
download | systemd-564cabd46c7c1532ad4d562bf8332eaed49ac201.tar.gz systemd-564cabd46c7c1532ad4d562bf8332eaed49ac201.tar.bz2 systemd-564cabd46c7c1532ad4d562bf8332eaed49ac201.zip |
lldp: check return value of lldp_tlv_packet_exit_container()
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd-network/lldp-tlv.c | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/src/libsystemd-network/lldp-tlv.c b/src/libsystemd-network/lldp-tlv.c index b3f0bfb1e9..4130f1adf7 100644 --- a/src/libsystemd-network/lldp-tlv.c +++ b/src/libsystemd-network/lldp-tlv.c @@ -380,7 +380,7 @@ int lldp_tlv_packet_exit_container(tlv_packet *m) { } static int lldp_tlv_packet_read_u16_tlv(tlv_packet *tlv, uint16_t type, uint16_t *value) { - int r; + int r, r2; assert_return(tlv, -EINVAL); @@ -389,16 +389,15 @@ static int lldp_tlv_packet_read_u16_tlv(tlv_packet *tlv, uint16_t type, uint16_t goto out; r = tlv_packet_read_u16(tlv, value); - - (void) lldp_tlv_packet_exit_container(tlv); + r2 = lldp_tlv_packet_exit_container(tlv); out: - return r; + return r < 0 ? r : r2; } static int lldp_tlv_packet_read_string_tlv(tlv_packet *tlv, uint16_t type, char **data, uint16_t *length) { char *s; - int r; + int r, r2; assert_return(tlv, -EINVAL); @@ -413,9 +412,9 @@ static int lldp_tlv_packet_read_string_tlv(tlv_packet *tlv, uint16_t type, char *data = (char *) s; out: - (void) lldp_tlv_packet_exit_container(tlv); + r2 = lldp_tlv_packet_exit_container(tlv); - return r; + return r < 0 ? r : r2; } int sd_lldp_packet_read_chassis_id(tlv_packet *tlv, @@ -423,7 +422,7 @@ int sd_lldp_packet_read_chassis_id(tlv_packet *tlv, uint8_t **data, uint16_t *length) { uint8_t subtype; - int r; + int r, r2; assert_return(tlv, -EINVAL); @@ -451,10 +450,10 @@ int sd_lldp_packet_read_chassis_id(tlv_packet *tlv, *type = subtype; out1: - (void) lldp_tlv_packet_exit_container(tlv); + r2 = lldp_tlv_packet_exit_container(tlv); out2: - return r; + return r < 0 ? r : r2; } int sd_lldp_packet_read_port_id(tlv_packet *tlv, @@ -463,7 +462,7 @@ int sd_lldp_packet_read_port_id(tlv_packet *tlv, uint16_t *length) { uint8_t subtype; char *s; - int r; + int r, r2; assert_return(tlv, -EINVAL); @@ -503,10 +502,10 @@ int sd_lldp_packet_read_port_id(tlv_packet *tlv, *type = subtype; out1: - (void) lldp_tlv_packet_exit_container(tlv); + r2 = lldp_tlv_packet_exit_container(tlv); out2: - return r; + return r < 0 ? r : r2; } int sd_lldp_packet_read_ttl(tlv_packet *tlv, uint16_t *ttl) { @@ -536,7 +535,7 @@ int sd_lldp_packet_read_system_capability(tlv_packet *tlv, uint16_t *data) { } int sd_lldp_packet_read_port_vlan_id(tlv_packet *tlv, uint16_t *id) { - int r; + int r, r2; assert_return(tlv, -EINVAL); @@ -545,15 +544,14 @@ int sd_lldp_packet_read_port_vlan_id(tlv_packet *tlv, uint16_t *id) { goto out; r = tlv_packet_read_u16(tlv, id); - - (void) lldp_tlv_packet_exit_container(tlv); + r2 = lldp_tlv_packet_exit_container(tlv); out: - return r; + return r < 0 ? r : r2; } int sd_lldp_packet_read_port_protocol_vlan_id(sd_lldp_packet *tlv, uint8_t *flags, uint16_t *id) { - int r; + int r, r2; assert_return(tlv, -EINVAL); @@ -565,14 +563,14 @@ int sd_lldp_packet_read_port_protocol_vlan_id(sd_lldp_packet *tlv, uint8_t *flag if (r >= 0) r = tlv_packet_read_u16(tlv, id); - (void) lldp_tlv_packet_exit_container(tlv); + r2 = lldp_tlv_packet_exit_container(tlv); out: - return r; + return r < 0 ? r : r2; } int sd_lldp_packet_read_vlan_name(tlv_packet *tlv, uint16_t *vlan_id, char **name, uint16_t *length) { - int r; + int r, r2; uint8_t len = 0; assert_return(tlv, -EINVAL); @@ -590,14 +588,14 @@ int sd_lldp_packet_read_vlan_name(tlv_packet *tlv, uint16_t *vlan_id, char **nam if (r >= 0 && len < *length) *length = len; - (void) lldp_tlv_packet_exit_container(tlv); + r2 = lldp_tlv_packet_exit_container(tlv); out: - return r; + return r < 0 ? r : r2; } int sd_lldp_packet_read_management_vid(tlv_packet *tlv, uint16_t *id) { - int r; + int r, r2; assert_return(tlv, -EINVAL); @@ -606,15 +604,14 @@ int sd_lldp_packet_read_management_vid(tlv_packet *tlv, uint16_t *id) { goto out; r = tlv_packet_read_u16(tlv, id); - - (void) lldp_tlv_packet_exit_container(tlv); + r2 = lldp_tlv_packet_exit_container(tlv); out: - return r; + return r < 0 ? r : r2; } int sd_lldp_packet_read_link_aggregation(sd_lldp_packet *tlv, uint8_t *status, uint32_t *id) { - int r; + int r, r2; assert_return(tlv, -EINVAL); @@ -626,10 +623,10 @@ int sd_lldp_packet_read_link_aggregation(sd_lldp_packet *tlv, uint8_t *status, u if (r >= 0) r = tlv_packet_read_u32(tlv, id); - (void) lldp_tlv_packet_exit_container(tlv); + r2 = lldp_tlv_packet_exit_container(tlv); out: - return r; + return r < 0 ? r : r2; } int sd_lldp_packet_get_destination_type(tlv_packet *tlv, int *dest) { |