Jim Meyering <jim(a)meyering.net> 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(a)redhat.com>
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, "(a)%s/.libvirt/libvirt-sock", userdir)
>= maxlen) {
VIR_FREE(userdir);
--
1.6.1.354.gd9e51