]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm/mdopen: fix coverity issue STRING_OVERFLOW
authorXiao Ni <xni@redhat.com>
Fri, 26 Jul 2024 07:14:10 +0000 (15:14 +0800)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Mon, 5 Aug 2024 09:13:04 +0000 (11:13 +0200)
Fix string overflow problems in mdopen.c

Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
mdopen.c

index c9fda131558bcefab1d842a7e1d2a2c2ab31d855..e49defb6744d0691b322aee7a3bf7e7699206267 100644 (file)
--- a/mdopen.c
+++ b/mdopen.c
@@ -376,7 +376,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
 
        sprintf(devname, "/dev/%s", devnm);
 
-       if (dev && dev[0] == '/')
+       if (dev && dev[0] == '/' && strlen(dev) < 400)
                strcpy(chosen, dev);
        else if (cname[0] == 0)
                strcpy(chosen, devname);