@@ -2249,26 +2249,28 @@ static int __init s390_ipl_init(void)
2249
2249
2250
2250
__initcall (s390_ipl_init );
2251
2251
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 )
2253
2253
{
2254
2254
int sx , dx ;
2255
2255
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 ++ ) {
2258
2259
if (src [sx ] == '"' )
2259
2260
continue ;
2260
- dst [dx ++ ] = src [sx ];
2261
- if (dx > = n )
2261
+ dst [dx ] = src [sx ];
2262
+ if (dx + 1 = = n )
2262
2263
break ;
2264
+ dx ++ ;
2263
2265
}
2266
+ dst [dx ] = '\0' ;
2264
2267
}
2265
2268
2266
2269
static int __init vmcmd_on_reboot_setup (char * str )
2267
2270
{
2268
2271
if (!machine_is_vm ())
2269
2272
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 ));
2272
2274
on_reboot_trigger .action = & vmcmd_action ;
2273
2275
return 1 ;
2274
2276
}
@@ -2278,8 +2280,7 @@ static int __init vmcmd_on_panic_setup(char *str)
2278
2280
{
2279
2281
if (!machine_is_vm ())
2280
2282
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 ));
2283
2284
on_panic_trigger .action = & vmcmd_action ;
2284
2285
return 1 ;
2285
2286
}
@@ -2289,8 +2290,7 @@ static int __init vmcmd_on_halt_setup(char *str)
2289
2290
{
2290
2291
if (!machine_is_vm ())
2291
2292
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 ));
2294
2294
on_halt_trigger .action = & vmcmd_action ;
2295
2295
return 1 ;
2296
2296
}
@@ -2300,8 +2300,7 @@ static int __init vmcmd_on_poff_setup(char *str)
2300
2300
{
2301
2301
if (!machine_is_vm ())
2302
2302
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 ));
2305
2304
on_poff_trigger .action = & vmcmd_action ;
2306
2305
return 1 ;
2307
2306
}
0 commit comments