-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

These were all discovered by Coverity. The fixes are pretty simple.

Patch 0001: If there's no orig_dn available, we need to fail here since
we can't determine the correct name. This occurs after we've already
processed the case where the name is single-valued.

Patch 0002: Only free *_name if _name is non-NULL.

Patch 0003: Check the correct result of talloc_strdup()

- -- 
Stephen Gallagher
RHCE 804006346421761

Delivering value year after year.
Red Hat ranks #1 in value among software vendors.
http://www.redhat.com/promo/vendor/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk2KBWIACgkQeiVVYja6o6OV4QCeKVr9LcDa/SISQlBmub8M7T2n
InwAoJkDVmi6uiYLxrBjJBkOGnkJjLPW
=IuCW
-----END PGP SIGNATURE-----
From 75087fdd4b6ecd1d5b68ef090069ece6e420a1f9 Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgall...@redhat.com>
Date: Wed, 23 Mar 2011 10:27:00 -0400
Subject: [PATCH 1/3] Don't crash if we get a multivalued name without an origDN

Coverity 10740 and 10739
---
 src/db/sysdb.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index 94738c606a9c4b69ce2cda1a1629aba9524cd68b..053094311c2611b9b2932344379793a3e5fb28a6 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -2195,7 +2195,9 @@ errno_t sysdb_attrs_primary_name(struct sysdb_ctx *sysdb,
         goto done;
     }
     if (orig_dn_el->num_values == 0) {
-        DEBUG(7, ("Original DN is not available.\n"));
+        DEBUG(1, ("Original DN is not available.\n"));
+        ret = EINVAL;
+        goto done;
     } else if (orig_dn_el->num_values == 1) {
         ret = sysdb_get_rdn(sysdb, tmpctx,
                             (const char *) orig_dn_el->values[0].data,
-- 
1.7.4

From 1c1dc55bfbb3aa3fd9622146141f2477d5d984b5 Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgall...@redhat.com>
Date: Wed, 23 Mar 2011 10:29:09 -0400
Subject: [PATCH 2/3] Don't crash on error if _name parameter unspecified

Coverity 10738
---
 src/db/sysdb.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index 053094311c2611b9b2932344379793a3e5fb28a6..0b02e9fa1d3109cd890b03fb541f83d223f20f55 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -244,14 +244,14 @@ errno_t sysdb_get_rdn(struct sysdb_ctx *ctx, void *memctx,
     val = ldb_dn_get_rdn_val(dn);
     if (val == NULL) {
         ret = EINVAL;
-        talloc_free(*_name);
+        if (_name) talloc_free(*_name);
         goto done;
     }
 
     *_val = talloc_strndup(memctx, (char *) val->data, val->length);
     if (!*_val) {
         ret = ENOMEM;
-        talloc_free(*_name);
+        if (_name) talloc_free(*_name);
         goto done;
     }
 
-- 
1.7.4

From 0d60621afc028597bb66a31d46d8325e52714d3e Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgall...@redhat.com>
Date: Wed, 23 Mar 2011 10:30:13 -0400
Subject: [PATCH 3/3] Check result of talloc_strdup() properly

Coverity 10737
---
 src/db/sysdb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index 0b02e9fa1d3109cd890b03fb541f83d223f20f55..cd785219b10ece35adce1dad9a2012bfaf7b31ec 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -235,7 +235,7 @@ errno_t sysdb_get_rdn(struct sysdb_ctx *ctx, void *memctx,
         }
 
         *_name = talloc_strdup(memctx, attr_name);
-        if (!_name) {
+        if (!*_name) {
             ret = ENOMEM;
             goto done;
         }
-- 
1.7.4

Attachment: 0001-Don-t-crash-if-we-get-a-multivalued-name-without-an-.patch.sig
Description: PGP signature

Attachment: 0002-Don-t-crash-on-error-if-_name-parameter-unspecified.patch.sig
Description: PGP signature

Attachment: 0003-Check-result-of-talloc_strdup-properly.patch.sig
Description: PGP signature

_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to