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

Re: [libvirt] [PATCH 2/7] conf: prevent crash with no uuid in cephx auth secret



On 2012年11月28日 21:34, Ján Tomko wrote:
Also remove the pointles check for NULL in auth.cephx.secret.uuid,
since this is a static array.

It's nice if there is log of coverity.

---
  src/conf/storage_conf.c |    8 +++-----
  1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 1c9934c..5a2cf1b 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -452,7 +452,7 @@ virStoragePoolDefParseAuthCephx(xmlXPathContextPtr ctxt,

      uuid = virXPathString("string(./auth/secret/@uuid)", ctxt);
      auth->secret.usage = virXPathString("string(./auth/secret/@usage)", ctxt);
-    if (uuid == NULL&&  auth->secret.usage == NULL) {
+    if (uuid == NULL || auth->secret.usage == NULL) {

This change forces both of "uuid" and "usage" to be specified.

But from the RNG schema:

  <define name='sourceinfoauthsecret'>
    <element name='secret'>
      <choice>
        <attribute name='uuid'>
          <text/>
        </attribute>
        <attribute name='usage'>
          <text/>
        </attribute>
      </choice>
    </element>
  </define>

Means that it allows only one of them specified.

Hm, from the schema, it should error out if both of them are
specified too. So either there is problem of either the schema
or the codes.

I think we have to figure out if the schema is correct first.

          virReportError(VIR_ERR_XML_ERROR, "%s",
                         _("missing auth secret uuid or usage attribute"));
          return -1;
@@ -976,10 +976,8 @@ virStoragePoolSourceFormat(virBufferPtr buf,
                            src->auth.cephx.username);

          virBufferAsprintf(buf,"      %s", "<secret");
-        if (src->auth.cephx.secret.uuid != NULL) {
-            virUUIDFormat(src->auth.cephx.secret.uuid, uuid);
-            virBufferAsprintf(buf," uuid='%s'", uuid);
-        }
+        virUUIDFormat(src->auth.cephx.secret.uuid, uuid);
+        virBufferAsprintf(buf," uuid='%s'", uuid);

This is fine though.


          if (src->auth.cephx.secret.usage != NULL) {
              virBufferAsprintf(buf," usage='%s'", src->auth.cephx.secret.usage);

Osier


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