1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

Check reallocated buffer for NULL before use

As *buf is reallocated in case CLVMD_CMD_TEST: test for NULL is needed
before printing status.
(realloc() == NULL and status != 0)
This commit is contained in:
Zdenek Kabelac 2010-11-30 22:11:26 +00:00
parent 8191fe4f4a
commit 41cf252f0b
2 changed files with 3 additions and 1 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.78 -
====================================
Check reallocated buffer for NULL before use in clvmd do_command().
Fix memory leak when VG allocation policy in metadata is invalid.
Ignore unrecognised allocation policy found in metadata instead of aborting.
Factor out tag printing into _out_tags and avoid leaking string buffer.

View File

@ -169,7 +169,8 @@ int do_command(struct local_client *client, struct clvm_header *msg, int msglen,
/* Check the status of the command and return the error text */
if (status) {
*retlen = 1 + snprintf(*buf, buflen, "%s", strerror(status));
*retlen = 1 + (*buf) ? snprintf(*buf, buflen, "%s",
strerror(status)) : -1;
}
return status;