xl: fix off-by-one mistake in block-attach handler
PATCH 1/1 xl: fix off-by-one mistake in block-attach handler
tools/libxl/xl_cmdimpl.c +1 -1
@@ -4280,7 +4280,7 @@ int main_blockattach(int argc, char **ar } disk.virtpath = argv[optind+2 ]; disk.unpluggable =1 ; - disk.readwrite = ((argc-optind <=2 ) || (argv[optind+3 ][0 ] =='w' )); + disk.readwrite = ((argc-optind <=3 ) || (argv[optind+3 ][0 ] =='w' ));if (domain_qualifier_to_domid (argv[optind], &fe_domid,0 ) <0 ) {fprintf (stderr,"%s is an invalid domain identifier\n" , argv[optind]);
tools/libxl/xl_cmdimpl.c +1 -1
@@ -4280,7 +4280,7 @@ int main_blockattach(int argc, char **ar } disk.virtpath = argv[optind+2 ]; disk.unpluggable =1 ; - disk.readwrite = ((argc-optind <=2 ) || (argv[optind+3 ][0 ] =='w' )); + disk.readwrite = ((argc-optind <=3 ) || (argv[optind+3 ][0 ] =='w' ));if (domain_qualifier_to_domid (argv[optind], &fe_domid,0 ) <0 ) {fprintf (stderr,"%s is an invalid domain identifier\n" , argv[optind]);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Jan Beulich writes ("[Xen-devel] [PATCH] xl: fix off-by-one mistake in block-attach handler"):
tools/libxl/xl_cmdimpl.c int main_blockattach(int argc, char **ar · line 4283
Quoted 10 lines
Signed-off-by Jan Beulich <[email protected]>tools/libxl/xl_cmdimpl.c +1
-1@@ -4280,7 +4280,7 @@ int main_blockattach(int argc, char **ar } disk.virtpath = argv[optind+2 ]; disk.unpluggable =1 ; - disk.readwrite = ((argc-optind <=2 ) || (argv[optind+3 ][0 ] =='w' )); + disk.readwrite = ((argc-optind <=3 ) || (argv[optind+3 ][0 ] =='w' ));
This idiom is pretty nasty. Perhaps we should rewrite it to:
+ disk.readwrite = (argc-optind > 3) ? (argv[optind+3][0] == 'w') : 1;
or some such ?
Ian.
Quoted 16 lines
Quoted 1 line
Quoted 1 line · Ian Jackson
Jan Beulich writes ("[Xen-devel] [PATCH] xl: fix off-by-one mistake in block-attach handler"):
tools/libxl/xl_cmdimpl.c int main_blockattach(int argc, char **ar · line 4283
Quoted 10 lines
Signed-off-by Jan Beulich <[email protected]>tools/libxl/xl_cmdimpl.c +1
-1@@ -4280,7 +4280,7 @@ int main_blockattach(int argc, char **ar } disk.virtpath = argv[optind+2 ]; disk.unpluggable =1 ; - disk.readwrite = ((argc-optind <=2 ) || (argv[optind+3 ][0 ] =='w' )); + disk.readwrite = ((argc-optind <=3 ) || (argv[optind+3 ][0 ] =='w' ));This idiom is pretty nasty. Perhaps we should rewrite it to:
Quoted 3 lines
+ disk.readwrite = (argc-optind > 3) ? (argv[optind+3][0] == 'w') : 1;
or some such ?
Honestly, I don't really care.
Jan