[lvm-devel] [PATCH 05/29] Test *buf for NULL

Zdenek Kabelac zkabelac at redhat.com
Thu Nov 25 10:55:09 UTC 2010


As we reallocate *buf in CLVMD_CMD_TEST we need to test for NULL
to print status to avoid printing to NULL buffer.
(realloc() == NULL & status != 0)

CHECKME:
General question - what is supposed to be written in *retlen for  *buf == NULL?

Signed-off-by: Zdenek Kabelac <zkabelac at redhat.com>
---
 daemons/clvmd/clvmd-command.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/daemons/clvmd/clvmd-command.c b/daemons/clvmd/clvmd-command.c
index 3500ca5..8d1dcff 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;
-- 
1.7.3.2




More information about the lvm-devel mailing list