summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-03-24 11:58:22 +0100
committerTom Gundersen <teg@jklm.no>2014-03-24 16:59:31 +0100
commite634cd409669130f77e552d2a57c1fca08738014 (patch)
tree7e252afaffa3d9c9cb97c0a031a92d9c53523c78
parentd39edfc72f9296078a18014627bf0a2543b60627 (diff)
sd-rtnl: message parsing - log when ignoring message attributes
-rw-r--r--src/libsystemd/sd-rtnl/rtnl-message.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index 330f57f64c..652dc6ee81 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -1040,7 +1040,7 @@ int rtnl_message_parse(sd_rtnl_message *m,
int max,
struct rtattr *rta,
unsigned int rt_len) {
- int type;
+ unsigned short type;
size_t *tb;
tb = (size_t *) new0(size_t *, max);
@@ -1052,8 +1052,15 @@ int rtnl_message_parse(sd_rtnl_message *m,
for (; RTA_OK(rta, rt_len); rta = RTA_NEXT(rta, rt_len)) {
type = rta->rta_type;
- if (type <= max)
- tb[type] = (uint8_t *) rta - (uint8_t *) m->hdr;
+ if (type > max) {
+ log_debug("rtnl: message parse - ignore out of range attribute type");
+ continue;
+ }
+
+ if (tb[type])
+ log_debug("rtnl: message parse - overwriting repeated attribute");
+
+ tb[type] = (uint8_t *) rta - (uint8_t *) m->hdr;
}
*rta_offset_tb = tb;