提交 5eef7432 编写于 作者: M Martin Kletzander

fixed SegFault in virauth

No check for conn->uri being NULL in virAuthGetConfigFilePath (valid
state) made the client segfault. This happens for example with these
settings:
 - no virtualbox driver installed (modifies conn->uri)
 - no default URI set (VIRSH_DEFAULT_CONNECT_URI="",
   LIBVIRT_DEFAULT_URI="", uri_default="")
 - auth_sock_rw="sasl"
 - virsh run as root

That are unfortunately the settings with fresh Fedora 17 installation
with VDSM.

The check ought to be enough as conn->uri being NULL is valid in later
code and is handled properly.
上级 98518178
/* /*
* virauth.c: authentication related utility functions * virauth.c: authentication related utility functions
* *
* Copyright (C) 2012 Red Hat, Inc.
* Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.com> * Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.com>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
...@@ -54,14 +55,16 @@ int virAuthGetConfigFilePath(virConnectPtr conn, ...@@ -54,14 +55,16 @@ int virAuthGetConfigFilePath(virConnectPtr conn,
return 0; return 0;
} }
for (i = 0 ; i < conn->uri->paramsCount ; i++) { if (conn && conn->uri) {
if (STREQ_NULLABLE(conn->uri->params[i].name, "authfile") && for (i = 0 ; i < conn->uri->paramsCount ; i++) {
conn->uri->params[i].value) { if (STREQ_NULLABLE(conn->uri->params[i].name, "authfile") &&
VIR_DEBUG("Using path from URI '%s'", conn->uri->params[i].value) {
conn->uri->params[i].value); VIR_DEBUG("Using path from URI '%s'",
if (!(*path = strdup(conn->uri->params[i].value))) conn->uri->params[i].value);
goto no_memory; if (!(*path = strdup(conn->uri->params[i].value)))
return 0; goto no_memory;
return 0;
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册