1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Do not send random bytes in message

Fixing few issues:

struct clvm_header  contains  'char args[1]' - so adding '+ 1' here
for message length calculation is 1 byte off.
Message with last byte uninitialized is then passed to write function.
Update also related arglen.

Initialise xid and clintid to 0.

Memory allocation is checked for NULL
This commit is contained in:
Zdenek Kabelac 2011-03-08 22:48:50 +00:00
parent e134ce7c3c
commit ee12300a56
2 changed files with 9 additions and 3 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.85 -
===================================
Send 1 byte shorted fully initialised local clvmd messages.
Support --help option for clvmd and return error for unknown option.
Use system page size and not hardcoded value in locking code check.
Fix reading of released memory for printing segment type.

View File

@ -1749,13 +1749,18 @@ static void send_local_reply(struct local_client *client, int status, int fd)
}
/* Add in the size of our header */
message_len = message_len + sizeof(struct clvm_header) + 1;
replybuf = malloc(message_len);
message_len = message_len + sizeof(struct clvm_header);
if (!(replybuf = malloc(message_len))) {
DEBUGLOG("Memory allocation fails\n");
return;
}
clientreply = (struct clvm_header *) replybuf;
clientreply->status = status;
clientreply->cmd = CLVMD_CMD_REPLY;
clientreply->node[0] = '\0';
clientreply->xid = 0;
clientreply->clientid = 0;
clientreply->flags = 0;
ptr = clientreply->args;
@ -1790,7 +1795,7 @@ static void send_local_reply(struct local_client *client, int status, int fd)
/* Terminate with an empty node name */
*ptr = '\0';
clientreply->arglen = ptr - clientreply->args + 1;
clientreply->arglen = ptr - clientreply->args;
/* And send it */
send_message(replybuf, message_len, our_csid, fd,