[libvirt] [PATCH] util: Resolve coverity issues

Wang King king.wang at huawei.com
Wed Apr 12 08:22:57 UTC 2017


Coverity complains about virBufferCurrentContent might be return null when calling
strlen, so check virBufferError first before calling strlen.
---
 src/util/virsystemd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index ceb1c1a..83737a2 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -135,6 +135,8 @@ virSystemdAppendValidMachineName(virBufferPtr buf,
     bool skip_dot = false;
 
     for (; *name; name++) {
+        if (virBufferError(buf))
+            break;
         if (strlen(virBufferCurrentContent(buf)) >= 64)
             break;
 
-- 
2.8.3





More information about the libvir-list mailing list