From: Wang King Date: Wed, 12 Apr 2017 08:22:57 +0000 (+0800) Subject: util: systemd: Don't strlen a possibly NULL string X-Git-Tag: v3.3.0-rc1~197 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5ca209f5848c68334c06cb2955758bd486fd149;p=thirdparty%2Flibvirt.git util: systemd: Don't strlen a possibly NULL string Coverity complains about virBufferCurrentContent might be return null when calling strlen, so check virBufferError first before calling strlen. --- diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index ceb1c1a958..83737a2c6f 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;