diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2010-11-30 22:11:26 +0000 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2010-11-30 22:11:26 +0000 |
commit | 41cf252f0b3f30cdad57c1514b5974956e1c635e (patch) | |
tree | 052b4e45cde6ba819b04c1d1d6973502722475f5 | |
parent | 8191fe4f4aebfa6ef55977ba6dfa8ebe01f8d06f (diff) | |
download | lvm2-41cf252f0b3f30cdad57c1514b5974956e1c635e.tar.gz lvm2-41cf252f0b3f30cdad57c1514b5974956e1c635e.tar.xz lvm2-41cf252f0b3f30cdad57c1514b5974956e1c635e.zip |
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)
-rw-r--r-- | WHATS_NEW | 1 | ||||
-rw-r--r-- | daemons/clvmd/clvmd-command.c | 3 |
2 files changed, 3 insertions, 1 deletions
@@ -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. diff --git a/daemons/clvmd/clvmd-command.c b/daemons/clvmd/clvmd-command.c index 3500ca5d..8d1dcff5 100644 --- a/daemons/clvmd/clvmd-command.c +++ b/daemons/clvmd/clvmd-command.c @@ -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; |