Skip to contentSkip to conversation

master - cleanup: never return uninitialized buffer

PATCH Zdenek Kabelac 1 participant 1 message Aug 26, 2014

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e5356eeba10858c2bb0f57891c262f77707b19bc
Commit:        e5356eeba10858c2bb0f57891c262f77707b19bc
Parent:        8f518cf1979e4cbfce40f6ae1bed02bd5b9a5b35
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Thu Aug 21 15:35:29 2014 +0200
Committer:     Zdenek Kabelac <[email protected]>
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(-)
lib/config/config.c +3 -1
index a71cbdc..58efb31 100644
@@ -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",