summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2010-11-30 22:11:26 +0000
committerZdenek Kabelac <zkabelac@redhat.com>2010-11-30 22:11:26 +0000
commit41cf252f0b3f30cdad57c1514b5974956e1c635e (patch)
tree052b4e45cde6ba819b04c1d1d6973502722475f5
parent8191fe4f4aebfa6ef55977ba6dfa8ebe01f8d06f (diff)
downloadlvm2-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_NEW1
-rw-r--r--daemons/clvmd/clvmd-command.c3
2 files changed, 3 insertions, 1 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index c932ec55..d5f192b3 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -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;