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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]