summaryrefslogtreecommitdiffstats
path: root/daemons/ipa-kdb/ipa_kdb_mspac.c
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2013-02-07 13:17:28 +0100
committerMartin Kosek <mkosek@redhat.com>2013-02-12 10:37:23 +0100
commitce90a4538bb78eba310f34b3dc4b51413d50c4be (patch)
treeea083b169e6b5f843a590861102093f0e9ba3680 /daemons/ipa-kdb/ipa_kdb_mspac.c
parente234edc9957cd1f530b1eff632774a7e09dc1e18 (diff)
downloadfreeipa-ce90a4538bb78eba310f34b3dc4b51413d50c4be.tar.gz
freeipa-ce90a4538bb78eba310f34b3dc4b51413d50c4be.tar.xz
freeipa-ce90a4538bb78eba310f34b3dc4b51413d50c4be.zip
ipa-kdb: avoid ENOMEM when all SIDs are filtered out
When all SIDs in info3.sids structure were filtered out, we tried to talloc_realloc to zero memory size. talloc_realloc then returned NULL pointer and filter_login_info returned with ENOMEM. The code now rather frees the SID array and set info3.sidcount to correct value.
Diffstat (limited to 'daemons/ipa-kdb/ipa_kdb_mspac.c')
-rw-r--r--daemons/ipa-kdb/ipa_kdb_mspac.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/daemons/ipa-kdb/ipa_kdb_mspac.c b/daemons/ipa-kdb/ipa_kdb_mspac.c
index ee1c6124f..7307071a0 100644
--- a/daemons/ipa-kdb/ipa_kdb_mspac.c
+++ b/daemons/ipa-kdb/ipa_kdb_mspac.c
@@ -1288,11 +1288,21 @@ static krb5_error_code filter_logon_info(krb5_context context,
} while (i < count);
if (j != 0) {
- info->info->info3.sids = talloc_realloc(memctx, info->info->info3.sids, struct netr_SidAttr, count-j);
- info->info->info3.sidcount = count-j;
- if (!info->info->info3.sids) {
+ count = count-j;
+ if (count == 0) {
+ /* All SIDs were filtered out */
info->info->info3.sidcount = 0;
- return ENOMEM;
+ talloc_free(info->info->info3.sids);
+ info->info->info3.sids = NULL;
+ } else {
+ info->info->info3.sids = talloc_realloc(memctx,
+ info->info->info3.sids,
+ struct netr_SidAttr, count);
+ if (!info->info->info3.sids) {
+ info->info->info3.sidcount = 0;
+ return ENOMEM;
+ }
+ info->info->info3.sidcount = count;
}
}
}