@@ -2249,26 +2249,28 @@ static int __init s390_ipl_init(void)
22492249
22502250__initcall (s390_ipl_init );
22512251
2252- static void __init strncpy_skip_quote (char * dst , char * src , int n )
2252+ static void __init strscpy_skip_quote (char * dst , char * src , int n )
22532253{
22542254 int sx , dx ;
22552255
2256- dx = 0 ;
2257- for (sx = 0 ; src [sx ] != 0 ; sx ++ ) {
2256+ if (!n )
2257+ return ;
2258+ for (sx = 0 , dx = 0 ; src [sx ]; sx ++ ) {
22582259 if (src [sx ] == '"' )
22592260 continue ;
2260- dst [dx ++ ] = src [sx ];
2261- if (dx > = n )
2261+ dst [dx ] = src [sx ];
2262+ if (dx + 1 = = n )
22622263 break ;
2264+ dx ++ ;
22632265 }
2266+ dst [dx ] = '\0' ;
22642267}
22652268
22662269static int __init vmcmd_on_reboot_setup (char * str )
22672270{
22682271 if (!machine_is_vm ())
22692272 return 1 ;
2270- strncpy_skip_quote (vmcmd_on_reboot , str , VMCMD_MAX_SIZE );
2271- vmcmd_on_reboot [VMCMD_MAX_SIZE ] = 0 ;
2273+ strscpy_skip_quote (vmcmd_on_reboot , str , sizeof (vmcmd_on_reboot ));
22722274 on_reboot_trigger .action = & vmcmd_action ;
22732275 return 1 ;
22742276}
@@ -2278,8 +2280,7 @@ static int __init vmcmd_on_panic_setup(char *str)
22782280{
22792281 if (!machine_is_vm ())
22802282 return 1 ;
2281- strncpy_skip_quote (vmcmd_on_panic , str , VMCMD_MAX_SIZE );
2282- vmcmd_on_panic [VMCMD_MAX_SIZE ] = 0 ;
2283+ strscpy_skip_quote (vmcmd_on_panic , str , sizeof (vmcmd_on_panic ));
22832284 on_panic_trigger .action = & vmcmd_action ;
22842285 return 1 ;
22852286}
@@ -2289,8 +2290,7 @@ static int __init vmcmd_on_halt_setup(char *str)
22892290{
22902291 if (!machine_is_vm ())
22912292 return 1 ;
2292- strncpy_skip_quote (vmcmd_on_halt , str , VMCMD_MAX_SIZE );
2293- vmcmd_on_halt [VMCMD_MAX_SIZE ] = 0 ;
2293+ strscpy_skip_quote (vmcmd_on_halt , str , sizeof (vmcmd_on_halt ));
22942294 on_halt_trigger .action = & vmcmd_action ;
22952295 return 1 ;
22962296}
@@ -2300,8 +2300,7 @@ static int __init vmcmd_on_poff_setup(char *str)
23002300{
23012301 if (!machine_is_vm ())
23022302 return 1 ;
2303- strncpy_skip_quote (vmcmd_on_poff , str , VMCMD_MAX_SIZE );
2304- vmcmd_on_poff [VMCMD_MAX_SIZE ] = 0 ;
2303+ strscpy_skip_quote (vmcmd_on_poff , str , sizeof (vmcmd_on_poff ));
23052304 on_poff_trigger .action = & vmcmd_action ;
23062305 return 1 ;
23072306}
0 commit comments