diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd-network/lldp-tlv.c | 38 | ||||
-rw-r--r-- | src/shared/conf-parser.c | 28 |
2 files changed, 29 insertions, 37 deletions
diff --git a/src/libsystemd-network/lldp-tlv.c b/src/libsystemd-network/lldp-tlv.c index a539b5dfea..7890160497 100644 --- a/src/libsystemd-network/lldp-tlv.c +++ b/src/libsystemd-network/lldp-tlv.c @@ -387,12 +387,11 @@ static int lldp_tlv_packet_read_u16_tlv(tlv_packet *tlv, uint16_t type, uint16_t r = lldp_tlv_packet_enter_container(tlv, type); if (r < 0) - goto out; + return r; r = tlv_packet_read_u16(tlv, value); r2 = lldp_tlv_packet_exit_container(tlv); - out: return r < 0 ? r : r2; } @@ -429,18 +428,18 @@ int sd_lldp_packet_read_chassis_id(tlv_packet *tlv, r = lldp_tlv_packet_enter_container(tlv, LLDP_TYPE_CHASSIS_ID); if (r < 0) - goto out2; + return r; r = tlv_packet_read_u8(tlv, &subtype); if (r < 0) - goto out1; + goto out; switch (subtype) { case LLDP_CHASSIS_SUBTYPE_MAC_ADDRESS: r = tlv_packet_read_bytes(tlv, data, length); if (r < 0) - goto out1; + goto out; break; default: @@ -450,10 +449,9 @@ int sd_lldp_packet_read_chassis_id(tlv_packet *tlv, *type = subtype; - out1: + out: r2 = lldp_tlv_packet_exit_container(tlv); - out2: return r < 0 ? r : r2; } @@ -469,11 +467,11 @@ int sd_lldp_packet_read_port_id(tlv_packet *tlv, r = lldp_tlv_packet_enter_container(tlv, LLDP_TYPE_PORT_ID); if (r < 0) - goto out2; + return r; r = tlv_packet_read_u8(tlv, &subtype); if (r < 0) - goto out1; + goto out; switch (subtype) { case LLDP_PORT_SUBTYPE_PORT_COMPONENT: @@ -483,7 +481,7 @@ int sd_lldp_packet_read_port_id(tlv_packet *tlv, r = tlv_packet_read_string(tlv, &s, length); if (r < 0) - goto out1; + goto out; *data = (uint8_t *) s; @@ -492,7 +490,7 @@ int sd_lldp_packet_read_port_id(tlv_packet *tlv, r = tlv_packet_read_bytes(tlv, data, length); if (r < 0) - goto out1; + goto out; break; default: @@ -502,10 +500,9 @@ int sd_lldp_packet_read_port_id(tlv_packet *tlv, *type = subtype; - out1: + out: r2 = lldp_tlv_packet_exit_container(tlv); - out2: return r < 0 ? r : r2; } @@ -542,12 +539,11 @@ int sd_lldp_packet_read_port_vlan_id(tlv_packet *tlv, uint16_t *id) { r = lldp_tlv_packet_enter_container_oui(tlv, LLDP_OUI_802_1, LLDP_OUI_SUBTYPE_802_1_PORT_VLAN_ID); if (r < 0) - goto out; + return r; r = tlv_packet_read_u16(tlv, id); r2 = lldp_tlv_packet_exit_container(tlv); - out: return r < 0 ? r : r2; } @@ -558,7 +554,7 @@ int sd_lldp_packet_read_port_protocol_vlan_id(sd_lldp_packet *tlv, uint8_t *flag r = lldp_tlv_packet_enter_container_oui(tlv, LLDP_OUI_802_1, LLDP_OUI_SUBTYPE_802_1_PORT_PROTOCOL_VLAN_ID); if (r < 0) - goto out; + return r; r = tlv_packet_read_u8(tlv, flags); if (r >= 0) @@ -566,7 +562,6 @@ int sd_lldp_packet_read_port_protocol_vlan_id(sd_lldp_packet *tlv, uint8_t *flag r2 = lldp_tlv_packet_exit_container(tlv); - out: return r < 0 ? r : r2; } @@ -578,7 +573,7 @@ int sd_lldp_packet_read_vlan_name(tlv_packet *tlv, uint16_t *vlan_id, char **nam r = lldp_tlv_packet_enter_container_oui(tlv, LLDP_OUI_802_1, LLDP_OUI_SUBTYPE_802_1_VLAN_NAME); if (r < 0) - goto out; + return r; r = tlv_packet_read_u16(tlv, vlan_id); if (r >= 0) @@ -591,7 +586,6 @@ int sd_lldp_packet_read_vlan_name(tlv_packet *tlv, uint16_t *vlan_id, char **nam r2 = lldp_tlv_packet_exit_container(tlv); - out: return r < 0 ? r : r2; } @@ -602,12 +596,11 @@ int sd_lldp_packet_read_management_vid(tlv_packet *tlv, uint16_t *id) { r = lldp_tlv_packet_enter_container_oui(tlv, LLDP_OUI_802_1, LLDP_OUI_SUBTYPE_802_1_MANAGEMENT_VID); if (r < 0) - goto out; + return r; r = tlv_packet_read_u16(tlv, id); r2 = lldp_tlv_packet_exit_container(tlv); - out: return r < 0 ? r : r2; } @@ -618,7 +611,7 @@ int sd_lldp_packet_read_link_aggregation(sd_lldp_packet *tlv, uint8_t *status, u r = lldp_tlv_packet_enter_container_oui(tlv, LLDP_OUI_802_1, LLDP_OUI_SUBTYPE_802_1_LINK_AGGREGATION); if (r < 0) - goto out; + return r; r = tlv_packet_read_u8(tlv, status); if (r >= 0) @@ -626,7 +619,6 @@ int sd_lldp_packet_read_link_aggregation(sd_lldp_packet *tlv, uint8_t *status, u r2 = lldp_tlv_packet_exit_container(tlv); - out: return r < 0 ? r : r2; } diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 3f8eaf7d9a..486122b0fd 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -702,9 +702,6 @@ int config_parse_strv(const char *unit, void *userdata) { char ***sv = data; - const char *word, *state; - size_t l; - int r; assert(filename); assert(lvalue); @@ -727,25 +724,28 @@ int config_parse_strv(const char *unit, return 0; } - FOREACH_WORD_QUOTED(word, l, rvalue, state) { - char *n; - - n = strndup(word, l); - if (!n) + for (;;) { + char *word = NULL; + int r; + r = extract_first_word(&rvalue, &word, WHITESPACE, EXTRACT_QUOTES); + if (r == 0) + break; + if (r == -ENOMEM) return log_oom(); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, r, "Invalid syntax, ignoring: %s", rvalue); + break; + } - if (!utf8_is_valid(n)) { + if (!utf8_is_valid(word)) { log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, rvalue); - free(n); + free(word); continue; } - - r = strv_consume(sv, n); + r = strv_consume(sv, word); if (r < 0) return log_oom(); } - if (!isempty(state)) - log_syntax(unit, LOG_ERR, filename, line, 0, "Trailing garbage, ignoring."); return 0; } |