diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2012-09-09 21:07:37 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2012-09-10 10:32:29 +0200 |
commit | 6a8999bf933f72923a271831d85a01ef88a81f39 (patch) | |
tree | 88716952059d2de92d9524de67be55bc232d2492 /src | |
parent | f74707245f0517e8d1f2fa7817600ecbc71680c1 (diff) | |
download | sssd-6a8999bf933f72923a271831d85a01ef88a81f39.tar.gz sssd-6a8999bf933f72923a271831d85a01ef88a81f39.tar.xz sssd-6a8999bf933f72923a271831d85a01ef88a81f39.zip |
SYSDB: NULL-terminate the output of sysdb_get_{ranges,subdomains}
Diffstat (limited to 'src')
-rw-r--r-- | src/db/sysdb_ranges.c | 3 | ||||
-rw-r--r-- | src/db/sysdb_subdomains.c | 4 | ||||
-rw-r--r-- | src/tests/sysdb-tests.c | 4 |
3 files changed, 7 insertions, 4 deletions
diff --git a/src/db/sysdb_ranges.c b/src/db/sysdb_ranges.c index 416bcdd0..f100f5b8 100644 --- a/src/db/sysdb_ranges.c +++ b/src/db/sysdb_ranges.c @@ -78,7 +78,7 @@ errno_t sysdb_get_ranges(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb, goto done; } - list = talloc_zero_array(tmp_ctx, struct range_info *, res->count); + list = talloc_zero_array(tmp_ctx, struct range_info *, res->count + 1); if (list == NULL) { ret = ENOMEM; goto done; @@ -142,6 +142,7 @@ errno_t sysdb_get_ranges(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb, goto done; } } + list[res->count] = NULL; *range_count = res->count; *range_list = talloc_steal(mem_ctx, list); diff --git a/src/db/sysdb_subdomains.c b/src/db/sysdb_subdomains.c index 96b8b4b2..b3998a2d 100644 --- a/src/db/sysdb_subdomains.c +++ b/src/db/sysdb_subdomains.c @@ -59,7 +59,7 @@ errno_t sysdb_get_subdomains(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb, goto done; } - list = talloc_zero_array(tmp_ctx, struct sysdb_subdom *, res->count); + list = talloc_zero_array(tmp_ctx, struct sysdb_subdom *, res->count + 1); if (list == NULL) { ret = ENOMEM; goto done; @@ -117,6 +117,8 @@ errno_t sysdb_get_subdomains(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb, } } + list[res->count] = NULL; + *subdomain_count = res->count; *subdomain_list = talloc_steal(mem_ctx, list); ret = EOK; diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c index be86f846..88d959c0 100644 --- a/src/tests/sysdb-tests.c +++ b/src/tests/sysdb-tests.c @@ -3414,7 +3414,7 @@ START_TEST(test_sysdb_subdomain_create) fail_unless(ret == EOK, "sysdb_get_subdomains failed with [%d][%s]", ret, strerror(ret)); fail_unless(cur_subdomains != NULL, "No sub-domains returned."); - fail_unless(cur_subdomains[0] == NULL, "No empyt sub-domain list returned."); + fail_unless(cur_subdomains[0] == NULL, "No empty sub-domain list returned."); ret = sysdb_update_subdomains(test_ctx->sysdb, num_subdom1, new_subdom1); fail_unless(ret == EOK, "sysdb_update_subdomains failed with [%d][%s]", @@ -3453,7 +3453,7 @@ START_TEST(test_sysdb_subdomain_create) fail_unless(ret == EOK, "sysdb_get_subdomains failed with [%d][%s]", ret, strerror(ret)); fail_unless(cur_subdomains != NULL, "No sub-domains returned."); - fail_unless(cur_subdomains[0] == NULL, "No empyt sub-domain list returned."); + fail_unless(cur_subdomains[0] == NULL, "No empty sub-domain list returned."); } END_TEST |