summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Graf <tgr@lsx.localdomain>2008-05-14 21:08:06 (GMT)
committerThomas Graf <tgr@lsx.localdomain>2008-05-14 21:08:06 (GMT)
commit0cf780859cbce363a6e2cd4b8d19c5498a3530f5 (patch)
tree1caa26c26c02713db8bab0eb13f5f19533dc2189 /lib
parentb4fbe1d34d6f54045b5c6236d86aacd4340ec83d (diff)
downloadlibnl-0cf780859cbce363a6e2cd4b8d19c5498a3530f5.zip
libnl-0cf780859cbce363a6e2cd4b8d19c5498a3530f5.tar.gz
libnl-0cf780859cbce363a6e2cd4b8d19c5498a3530f5.tar.bz2
Check length of provided address label
Diffstat (limited to 'lib')
-rw-r--r--lib/route/addr.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/route/addr.c b/lib/route/addr.c
index 905dce2..1edcd69 100644
--- a/lib/route/addr.c
+++ b/lib/route/addr.c
@@ -850,10 +850,15 @@ int rtnl_addr_delete(struct nl_handle *handle, struct rtnl_addr *addr,
* @{
*/
-void rtnl_addr_set_label(struct rtnl_addr *addr, const char *label)
+int rtnl_addr_set_label(struct rtnl_addr *addr, const char *label)
{
- strncpy(addr->a_label, label, sizeof(addr->a_label) - 1);
+ if (strlen(label) > sizeof(addr->a_label) - 1)
+ return -NLE_RANGE;
+
+ strcpy(addr->a_label, label);
addr->ce_mask |= ADDR_ATTR_LABEL;
+
+ return 0;
}
char *rtnl_addr_get_label(struct rtnl_addr *addr)