Call srand() to make sure request handles are properly randomised

This commit is contained in:
Alex Young
2014-02-24 12:20:50 +00:00
parent 5185be39c9
commit 8cf92af900
4 changed files with 16 additions and 4 deletions

View File

@@ -103,10 +103,13 @@ int socket_nbd_write_hello(int fd, off64_t out_size)
void fill_request(struct nbd_request *request, int type, off64_t from, int len)
{
int32_t handle_i[2];
handle_i[0] = rand();
handle_i[1] = rand();
request->magic = htobe32(REQUEST_MAGIC);
request->type = htobe32(type);
((int*) request->handle)[0] = rand();
((int*) request->handle)[1] = rand();
memcpy( request->handle, handle_i, sizeof(request->handle) );
request->from = htobe64(from);
request->len = htobe32(len);
}