summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-rtnl/test-rtnl.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-03-23 21:44:47 +0100
committerTom Gundersen <teg@jklm.no>2014-03-23 21:54:16 +0100
commitf66eeb6bb636f8061bf45e6e8e24761e87510800 (patch)
tree9a58b940eb3b14c77abdc5456e03a2efe711918b /src/libsystemd/sd-rtnl/test-rtnl.c
parenta212d0dadd1e5e7bc0a57b8dfe2feb9111db2678 (diff)
sd-rtnl: message - protect against SEGFAULT when reading messages
Make sure the returned data fits the datatype we requested. Otherwise return -EIO. Also fix a broken test that this exposed.
Diffstat (limited to 'src/libsystemd/sd-rtnl/test-rtnl.c')
-rw-r--r--src/libsystemd/sd-rtnl/test-rtnl.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libsystemd/sd-rtnl/test-rtnl.c b/src/libsystemd/sd-rtnl/test-rtnl.c
index 6ecd6603ae..6d9159cd11 100644
--- a/src/libsystemd/sd-rtnl/test-rtnl.c
+++ b/src/libsystemd/sd-rtnl/test-rtnl.c
@@ -152,6 +152,7 @@ static void test_address_get(sd_rtnl *rtnl, int ifindex) {
sd_rtnl_message *m;
sd_rtnl_message *r;
struct in_addr in_data;
+ char *label;
assert_se(sd_rtnl_message_new_addr(rtnl, &m, RTM_GETADDR, ifindex, AF_INET) >= 0);
assert_se(m);
@@ -160,8 +161,7 @@ static void test_address_get(sd_rtnl *rtnl, int ifindex) {
assert_se(sd_rtnl_message_read_in_addr(r, IFA_LOCAL, &in_data) == 0);
assert_se(sd_rtnl_message_read_in_addr(r, IFA_ADDRESS, &in_data) == 0);
- assert_se(sd_rtnl_message_read_in_addr(r, IFA_LABEL, &in_data) == 0);
- assert_se(sd_rtnl_message_read_in_addr(r, IFA_CACHEINFO, &in_data) == 0);
+ assert_se(sd_rtnl_message_read_string(r, IFA_LABEL, &label) == 0);
assert_se(sd_rtnl_flush(rtnl) >= 0);
assert_se((m = sd_rtnl_message_unref(m)) == NULL);