summaryrefslogtreecommitdiff
path: root/bridge.c
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2018-08-12 22:08:22 +0200
committerHans Dedecker <dedeckeh@gmail.com>2018-08-14 17:06:38 +0200
commit522456b9f3ab07a78de17bf693abead4a296b028 (patch)
tree5e749e5e2aa3c4a3e77a0546d5148961398bccf6 /bridge.c
parent115a694ab9a44cd52a8ab18e07909c753de9fb94 (diff)
downloadnetifd-522456b9f3ab07a78de17bf693abead4a296b028.tar.gz
device: gracefully handle device names exceeding IFNAMESIZ
Instead of truncating the device name when it exceeds IFNAMSIZ length; let device_set_ifname return an error code and do not add the device to the device list. This avoids possible issues with device names becoming identical due the truncation and as a result unexpected behavior. Further let the different device types gracefully handle the error code returned by device_init Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'bridge.c')
-rw-r--r--bridge.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/bridge.c b/bridge.c
index 96e0209..8876871 100644
--- a/bridge.c
+++ b/bridge.c
@@ -720,7 +720,13 @@ bridge_create(const char *name, struct device_type *devtype,
return NULL;
dev = &bst->dev;
- device_init(dev, devtype, name);
+
+ if (device_init(dev, devtype, name) < 0) {
+ device_cleanup(dev);
+ free(bst);
+ return NULL;
+ }
+
dev->config_pending = true;
bst->retry.cb = bridge_retry_members;