[libvirt] [PATCH v2 1/6] openvz: Resolve Coverity FORWARD_NULL

John Ferlan jferlan at redhat.com
Fri Sep 25 16:31:40 UTC 2015


In openvzGetVPSUUID while parsing the conf_file, if "line" is for some
reason returned as NULL from a getline() call with a successful status,
then the subsequent call to strtok_r would attempt to reference the
'saveptr' which was initialized to NULL leading to an issue.

Altough getline() claims it would return an error, this does avoid
the problem and of course keep Coverity quiet

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/openvz/openvz_conf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index db0a9a7..fb8768a 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -956,7 +956,7 @@ openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len)
         goto cleanup;
 
     while (1) {
-        if (getline(&line, &line_size, fp) < 0) {
+        if (getline(&line, &line_size, fp) < 0 || !line) {
             if (feof(fp)) { /* EOF, UUID was not found */
                 uuidstr[0] = 0;
                 break;
-- 
2.1.0




More information about the libvir-list mailing list