summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-07-12 18:17:35 +0100
committerRichard W.M. Jones <rjones@redhat.com>2011-07-12 18:44:45 +0100
commit0344248af55802bbbd816b349ec1ba9305996f6e (patch)
treef2e4f76e56b059f4d37eeea802de9140d6b5dbb6
parentc0f72f13c075a754afa7870ecf105138fba821bb (diff)
downloadlibguestfs-0344248af55802bbbd816b349ec1ba9305996f6e.tar.gz
libguestfs-0344248af55802bbbd816b349ec1ba9305996f6e.tar.xz
libguestfs-0344248af55802bbbd816b349ec1ba9305996f6e.zip
protocol: Force optargs_bitmask to be passed as 0 for non-opt actions.
If the action doesn't take optional arguments, nevertheless force the optargs_bitmask field in the header to be passed as 0, and give an error if not.
-rw-r--r--generator/generator_daemon.ml15
1 files changed, 13 insertions, 2 deletions
diff --git a/generator/generator_daemon.ml b/generator/generator_daemon.ml
index f5c1fa3e..7e18e35a 100644
--- a/generator/generator_daemon.ml
+++ b/generator/generator_daemon.ml
@@ -122,7 +122,11 @@ and generate_daemon_actions () =
let is_filein =
List.exists (function FileIn _ -> true | _ -> false) args in
- (* Reject unknown optional arguments. *)
+ (* Reject unknown optional arguments.
+ * Note this code is included even for calls with no optional
+ * args because the caller must not pass optargs_bitmask != 0
+ * in that case.
+ *)
if optargs <> [] then (
let len = List.length optargs in
let mask = Int64.lognot (Int64.pred (Int64.shift_left 1L len)) in
@@ -132,8 +136,15 @@ and generate_daemon_actions () =
pr " reply_with_error (\"unknown option in optional arguments bitmask (this can happen if a program is compiled against a newer version of libguestfs, then run against an older version of the daemon)\");\n";
pr " goto done;\n";
pr " }\n";
- pr "\n"
+ ) else (
+ pr " if (optargs_bitmask != 0) {\n";
+ if is_filein then
+ pr " cancel_receive ();\n";
+ pr " reply_with_error (\"header optargs_bitmask field must be passed as 0 for calls that don't take optional arguments\");\n";
+ pr " goto done;\n";
+ pr " }\n";
);
+ pr "\n";
(* Decode arguments. *)
if args <> [] || optargs <> [] then (