[PATCH] blktrace: valid magic in received header always
authorJens Axboe <axboe@suse.de>
Tue, 21 Feb 2006 14:24:40 +0000 (15:24 +0100)
committerJens Axboe <axboe@suse.de>
Tue, 21 Feb 2006 14:24:40 +0000 (15:24 +0100)
blktrace.c

index a87ef0d55c14397b472561777fe63b3fdbbd3918..39280ca15d6808fce2a70c92c5c46c5da868ddee 100644 (file)
@@ -1370,7 +1370,7 @@ static int net_get_header(struct blktrace_net_hdr *bnh)
                }
        }
        fcntl(net_in_fd, F_SETFL, fl & ~O_NONBLOCK);
-       return 0;
+       return bytes_left;
 }
 
 static int net_server_loop(struct in_addr *cl_in_addr)
@@ -1387,10 +1387,16 @@ static int net_server_loop(struct in_addr *cl_in_addr)
        }
 
        if (!data_is_native) {
+               bnh.magic = be32_to_cpu(bnh.magic);
                bnh.cpu = be32_to_cpu(bnh.cpu);
                bnh.len = be32_to_cpu(bnh.len);
        }
 
+       if ((bnh.magic & 0xffffff00) != BLK_IO_TRACE_MAGIC) {
+               fprintf(stderr, "server: bad data magic\n");
+               return 1;
+       }
+
        /*
         * len == 0 means that the other end signalled end-of-run
         */