]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: systemd: Don't strlen a possibly NULL string
authorWang King <king.wang@huawei.com>
Wed, 12 Apr 2017 08:22:57 +0000 (16:22 +0800)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 12 Apr 2017 08:55:42 +0000 (10:55 +0200)
Coverity complains about virBufferCurrentContent might be return null
when calling strlen, so check virBufferError first before calling
strlen.

src/util/virsystemd.c

index ceb1c1a958a69b698d195ba6dd3c91f4ab422232..83737a2c6fd36ea909890dda3f8793282cf01032 100644 (file)
@@ -135,6 +135,8 @@ virSystemdAppendValidMachineName(virBufferPtr buf,
     bool skip_dot = false;
 
     for (; *name; name++) {
+        if (virBufferError(buf))
+            break;
         if (strlen(virBufferCurrentContent(buf)) >= 64)
             break;