daemon: Print error for invalid chunk.cancel field.
authorRichard W.M. Jones <rjones@redhat.com>
Fri, 18 Mar 2011 11:21:55 +0000 (11:21 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Fri, 18 Mar 2011 11:21:55 +0000 (11:21 +0000)
The chunk.cancel field should always be [0|1].  If it is not then
something has gone badly wrong -- probably loss of synchronization.
If this occurs print a debug message and return error from
receive_file function.

daemon/proto.c

index 90a8388..cef1146 100644 (file)
@@ -405,6 +405,13 @@ receive_file (receive_cb cb, void *opaque)
                "receive_file: got chunk: cancel = 0x%x, len = %d, buf = %p\n",
                chunk.cancel, chunk.data.data_len, chunk.data.data_val);
 
+    if (chunk.cancel != 0 && chunk.cancel != 1) {
+      fprintf (stderr,
+               "receive_file: chunk.cancel != [0|1] ... "
+               "continuing even though we have probably lost synchronization with the library\n");
+      return -1;
+    }
+
     if (chunk.cancel) {
       if (verbose)
         fprintf (stderr, "receive_file: received cancellation from library\n");