Re: [libvirt] [PATCH] qemud: don't dereference NULL on failed virGetUserDirectory

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

 



Jim Meyering <jim@xxxxxxxxxxxx> wrote:
> I spotted this while merging my unix_sock_dir changes:
...
>          char *userdir = virGetUserDirectory(NULL, uid);
> +        if (userdir == NULL) {
> +            /* give no diagnostic here; virGetUserDirectory reports OOM  */

It can also fail due to getpwuid_r failure.
Here's the patch with corrected comment/log:

>From f3f134d51ac6e90f30d5859690fe57dc16d955aa Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@xxxxxxxxxx>
Date: Fri, 23 Jan 2009 13:59:28 +0100
Subject: [PATCH] qemud: don't dereference NULL on failed virGetUserDirectory

* qemud/qemud.c (qemudInitPaths): Return right away,
upon virGetUserDirectory.
---
 qemud/qemud.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/qemud/qemud.c b/qemud/qemud.c
index 55f31d5..eb91533 100644
--- a/qemud/qemud.c
+++ b/qemud/qemud.c
@@ -719,6 +719,10 @@ static int qemudInitPaths(struct qemud_server *server,
             goto snprintf_error;
     } else {
         char *userdir = virGetUserDirectory(NULL, uid);
+        if (userdir == NULL) {
+            /* Do not diagnose here; virGetUserDirectory does that.  */
+            return -1;
+        }

         if (snprintf(sockname, maxlen, "@%s/.libvirt/libvirt-sock", userdir) >= maxlen) {
             VIR_FREE(userdir);
--
1.6.1.354.gd9e51

--
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]