diff options
author | Nathan Kinder <nkinder@redhat.com> | 2010-09-08 10:47:07 -0700 |
---|---|---|
committer | Nathan Kinder <nkinder@redhat.com> | 2010-09-08 10:47:07 -0700 |
commit | b2962bd5ecab66571b2afe223a61ff1a7d53dc3c (patch) | |
tree | 3e6b2fe2067c63c1d939a5025f196828da1f9285 | |
parent | 3835f3ccd452c8d8af26f54ac04433f9f581a2ff (diff) | |
download | ds-b2962bd5ecab66571b2afe223a61ff1a7d53dc3c.tar.gz ds-b2962bd5ecab66571b2afe223a61ff1a7d53dc3c.tar.xz ds-b2962bd5ecab66571b2afe223a61ff1a7d53dc3c.zip |
Bug 630096 - (cov#15447) - Check return value of idl_append_extend()
We should check the return type of idl_append_extend(), though it does
not seem possible that the return type will be anything other than 0.
The only time idl_append_extend() returns anything other than 0 is
when it is unable to allocate memory. Since the underlying allocation
function is slapi_ch_calloc(), the server will just exit if it runs
out of memory, which means we will never return up through
idl_append_extend(). The right thing to do from a code standpoint is
to still check for the return value though.
-rw-r--r-- | ldap/servers/slapd/back-ldbm/idl_new.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/ldap/servers/slapd/back-ldbm/idl_new.c b/ldap/servers/slapd/back-ldbm/idl_new.c index 20eee682..298d5e83 100644 --- a/ldap/servers/slapd/back-ldbm/idl_new.c +++ b/ldap/servers/slapd/back-ldbm/idl_new.c @@ -154,6 +154,7 @@ IDList * idl_new_fetch( ) { int ret = 0; + int idl_rc = 0; DBC *cursor = NULL; IDList *idl = NULL; DBT key; @@ -246,7 +247,12 @@ IDList * idl_new_fetch( memcpy(&id, dataret.data, sizeof(ID)); /* we got another ID, add it to our IDL */ - idl_append_extend(&idl, id); + idl_rc = idl_append_extend(&idl, id); + if (idl_rc) { + LDAPDebug(LDAP_DEBUG_ANY, "unable to extend id list (err=%d)\n", idl_rc, 0, 0); + idl_free(idl); idl = NULL; + goto error; + } count++; } @@ -275,7 +281,12 @@ IDList * idl_new_fetch( break; } /* we got another ID, add it to our IDL */ - idl_append_extend(&idl, id); + idl_rc = idl_append_extend(&idl, id); + if (idl_rc) { + LDAPDebug(LDAP_DEBUG_ANY, "unable to extend id list (err=%d)\n", idl_rc); + idl_free(idl); idl = NULL; + goto error; + } #if defined(DB_ALLIDS_ON_READ) /* enforce the allids read limit */ if (count > idl_new_get_allidslimit(a)) { |