Skip to contentSkip to conversation

xl: fix off-by-one mistake in block-attach handler

PATCH In review Jan Beulich 2 participants 3 messages Sep 21, 2010

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw

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
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.

#2 lore raw
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
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