[lvm-devel] master - cleanup: never return uninitialized buffer

Zdenek Kabelac zkabelac at fedoraproject.org
Tue Aug 26 12:17:34 UTC 2014


Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e5356eeba10858c2bb0f57891c262f77707b19bc
Commit:        e5356eeba10858c2bb0f57891c262f77707b19bc
Parent:        8f518cf1979e4cbfce40f6ae1bed02bd5b9a5b35
Author:        Zdenek Kabelac <zkabelac at redhat.com>
AuthorDate:    Thu Aug 21 15:35:29 2014 +0200
Committer:     Zdenek Kabelac <zkabelac at redhat.com>
CommitterDate: Tue Aug 26 14:13:06 2014 +0200

cleanup: never return uninitialized buffer

Coverity noticed this function may return untouched buffer,
however in this state can't really happen, but anyway
ensure on error path the buffer will have zero lenght string.
---
 lib/config/config.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/config/config.c b/lib/config/config.c
index a71cbdc..58efb31 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -602,8 +602,10 @@ static int _cfg_def_make_path(char *buf, size_t buf_size, int id, cfg_def_item_t
 	int parent_id = item->parent;
 	int count, n;
 
-	if (id == parent_id)
+	if (id == parent_id) {
+		buf[0] = '\0';
 		return 0;
+	}
 
 	count = _cfg_def_make_path(buf, buf_size, parent_id, cfg_def_get_item_p(parent_id), xlate);
 	if ((n = dm_snprintf(buf + count, buf_size - count, "%s%s%s%s",




More information about the lvm-devel mailing list