diff mbox series

[OpenWrt-Devel] netifd: make sure the vlan ifnmae fits into the buffer

Message ID 20180716083350.15696-1-john@phrozen.org
State Accepted
Delegated to: John Crispin
Headers show
Series [OpenWrt-Devel] netifd: make sure the vlan ifnmae fits into the buffer | expand

Commit Message

John Crispin July 16, 2018, 8:33 a.m. UTC
Signed-off-by: John Crispin <john@phrozen.org>
---
 vlan.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Rafał Miłecki July 16, 2018, 9 a.m. UTC | #1
Some nitpicking ;)

s/ifnmae/ifname/

On Mon, 16 Jul 2018 at 10:34, John Crispin <john@phrozen.org> wrote:
> Signed-off-by: John Crispin <john@phrozen.org>
> ---
>  vlan.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/vlan.c b/vlan.c
> index 067f624..43526d8 100644
> --- a/vlan.c
> +++ b/vlan.c
> @@ -104,6 +104,9 @@ static struct device *get_vlan_device(struct device *dev, int id, bool create)
>         struct vlan_device *vldev;
>         struct device_user *dep;
>
> +       if (strlen(dev->ifname) > (IFNAMSIZ - 6))
> +               return -ENAMETOOLONG;

You don't need braces around IFNAMSIZ - 6.
diff mbox series

Patch

diff --git a/vlan.c b/vlan.c
index 067f624..43526d8 100644
--- a/vlan.c
+++ b/vlan.c
@@ -104,6 +104,9 @@  static struct device *get_vlan_device(struct device *dev, int id, bool create)
 	struct vlan_device *vldev;
 	struct device_user *dep;
 
+	if (strlen(dev->ifname) > (IFNAMSIZ - 6))
+		return -ENAMETOOLONG;
+
 	/* look for an existing interface before creating a new one */
 	list_for_each_entry(dep, &dev->users.list, list.list) {
 		if (dep->cb != vlan_dev_cb)