From 8a8a182679a212421c191f45be0155b29cb74381 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 17 Dec 2010 12:37:49 +0000 Subject: [PATCH] Fix NULL pointer check for *buf As ternary operator has lower priority then add operation, this check was not doing what seemed to be expected. So enclose the test in braces and check for NULL in *buf. --- WHATS_NEW | 1 + daemons/clvmd/clvmd-command.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 03d2dc9cf..a99d32ec9 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.79 - =================================== + Fix NULL pointer check in error path in clvmd do_command(). (2.02.78) Fix device.c #include to ensure 64-bit fopen64 use. (2.02.51) Create /var/run/lvm directory during clvmd initialisation if missing. Use new dm_prepare_selinux_context instead of dm_set_selinux_context. diff --git a/daemons/clvmd/clvmd-command.c b/daemons/clvmd/clvmd-command.c index 915fcc7e3..49f119719 100644 --- a/daemons/clvmd/clvmd-command.c +++ b/daemons/clvmd/clvmd-command.c @@ -168,8 +168,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 + (*buf) ? dm_snprintf(*buf, buflen, "%s", - strerror(status)) : -1; + *retlen = 1 + ((*buf) ? dm_snprintf(*buf, buflen, "%s", + strerror(status)) : -1); } return status; -- 2.43.5