diff options
author | Dimitri John Ledkov <xnox@ubuntu.com> | 2017-05-02 20:32:42 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-05-02 15:32:42 -0400 |
commit | f00ff0de40030ed86e7d78c8c1f77b042b51d38c (patch) | |
tree | 03a50b922c2b8a8455fce12e5b6fbd4f0a4fa2b4 /src/libsystemd-network/network-internal.c | |
parent | b7674ecd5b456d31c7a459f002ccb995a2daec50 (diff) |
network: reject bridge port priorities above kernel's max value. (#5877)
Bridge port priority in the kernel can only be between 0 and 63. Therefore
reject values above maximum.
Fixes: #5729
Diffstat (limited to 'src/libsystemd-network/network-internal.c')
-rw-r--r-- | src/libsystemd-network/network-internal.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c index 092a1eabb0..337241a815 100644 --- a/src/libsystemd-network/network-internal.c +++ b/src/libsystemd-network/network-internal.c @@ -349,6 +349,45 @@ int config_parse_iaid(const char *unit, return 0; } +int config_parse_bridge_port_priority( + const char *unit, + const char *filename, + unsigned line, + const char *section, + unsigned section_line, + const char *lvalue, + int ltype, + const char *rvalue, + void *data, + void *userdata) { + + uint16_t i; + int r; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(data); + + r = safe_atou16(rvalue, &i); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, r, + "Failed to parse bridge port priority, ignoring: %s", rvalue); + return 0; + } + + if (i > LINK_BRIDGE_PORT_PRIORITY_MAX) { + log_syntax(unit, LOG_ERR, filename, line, r, + "Bridge port priority is larger than maximum %u, ignoring: %s", LINK_BRIDGE_PORT_PRIORITY_MAX, rvalue); + return 0; + } + + *((uint16_t *)data) = i; + + return 0; +} + + void serialize_in_addrs(FILE *f, const struct in_addr *addresses, size_t size) { unsigned i; |