mdopen: Prevent overrunning the devname buffer when copying devnm into it for long md names.
Subsystems (2)
PATCH v2 1/1 mdopen: Prevent overrunning the devname buffer when copying devnm into it for long md names.
Linux allows for 32 character device names. When using the maximum size device name and also storing "/dev/", devname needs to be 37 character long to store the complete device name. i.e. "/dev/md_abcdefghijklmnopqrstuvwxyz12\0"
Signed-Off: Robert LeBlanc<[email protected]>
--- mdopen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mdopen.c +1 -1
@@ -144,7 +144,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,struct createinfo *ci =conf_get_create_info ();int parts;char *cname; -char devname[20 ]; +char devname[37 ];char devnm[32 ];char cbuf[400 ];if (chosen ==NULL )
Signature · 1 line
2.9.3
Quoted 14 lines · Robert LeBlanc
Linux allows for 32 character device names. When using the maximum size device name and also storing "
/dev/", devname needs to be 37 character long to store the complete device name. i.e. "/dev/md_abcdefghijklmnopqrstuvwxyz12\0"Signed-Off: Robert LeBlanc<[email protected]>
--- mdopen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mdopen.c +0
-0
mdopen.c int create_mddev(char *dev, char *name, int autof, int trustworthy, · line 147
Quoted 5 lines
mdopen.c +1
-1@@ -144,7 +144,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,struct createinfo *ci =conf_get_create_info ();int parts;char *cname; -char devname[20 ]; +char devname[37 ];
I think you want 38 here.
5 + 32 + '\0'.
Quoted 6 lines
mdopen.c +0
-1char devnm[32 ];char cbuf[400 ];if (chosen ==NULL ) --2.9.3
Also a sprintf() to snprintf() cleanup might not be a bad idea ..
Signature · 1 line
Shaun Tancheff
Quoted 10 lines · Shaun Tancheff
Quoted 9 lines · Robert LeBlanc
Linux allows for 32 character device names. When using the maximum size device name and also storing "
/dev/", devname needs to be 37 character long to store the complete device name. i.e. "/dev/md_abcdefghijklmnopqrstuvwxyz12\0"Signed-Off: Robert LeBlanc<[email protected]>
--- mdopen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
mdopen.c int create_mddev(char *dev, char *name, int autof, int trustworthy, · line 147
Quoted 10 lines
mdopen.c +1
-1@@ -144,7 +144,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,struct createinfo *ci =conf_get_create_info ();int parts;char *cname; -char devname[20 ]; +char devname[37 ];I think you want 38 here.
5 + 32 + '\0'.Quoted 1 line
mdopen.c +0
-0char devnm[32 ];
Ah sorry, that 32 was including the null already
implied by devnm.
Looks fine.
Quoted 9 lines
Quoted 5 lines
mdopen.c +0
-1char cbuf[400 ];if (chosen ==NULL ) --2.9.3
Also a
sprintf()tosnprintf()cleanup might not be a bad idea .. --
Shaun Tancheff
Signature · 1 line
Shaun Tancheff
Jes Sorensen
AppliedQuoted 8 lines · Robert LeBlanc
Linux allows for 32 character device names. When using the maximum size device name and also storing "
/dev/", devname needs to be 37 character long to store the complete device name. i.e. "/dev/md_abcdefghijklmnopqrstuvwxyz12\0"Signed-Off: Robert LeBlanc<[email protected]>
--- mdopen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Looks good - I corrected your comment to fit into a proper editor width of 80 characters, and also fixed up the SOB since it needs to say Signed-off-by rather than signed-off.
Applied!
Jes