summaryrefslogtreecommitdiffstats
path: root/daemons
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2015-05-26 13:00:26 +0200
committerTomas Babej <tbabej@redhat.com>2015-07-08 01:56:52 +0200
commit3f7481a220371e1a1ff0babae39e26f78a8948ad (patch)
treec9530b23feb311adcd8e2bc56d83a3f52420d787 /daemons
parent7a1b4dcafc35a9bd0a48bd6da342970f31426264 (diff)
downloadfreeipa-3f7481a220371e1a1ff0babae39e26f78a8948ad.tar.gz
freeipa-3f7481a220371e1a1ff0babae39e26f78a8948ad.tar.xz
freeipa-3f7481a220371e1a1ff0babae39e26f78a8948ad.zip
ipa-kdb: make string_to_sid() and dom_sid_string() more robust
Reviewed-By: Tomas Babej <tbabej@redhat.com>
Diffstat (limited to 'daemons')
-rw-r--r--daemons/ipa-kdb/ipa_kdb_mspac.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/daemons/ipa-kdb/ipa_kdb_mspac.c b/daemons/ipa-kdb/ipa_kdb_mspac.c
index 336d136e7..3c0dca839 100644
--- a/daemons/ipa-kdb/ipa_kdb_mspac.c
+++ b/daemons/ipa-kdb/ipa_kdb_mspac.c
@@ -96,6 +96,10 @@ int string_to_sid(const char *str, struct dom_sid *sid)
char *t;
int i;
+ if (str == NULL) {
+ return EINVAL;
+ }
+
memset(sid, '\0', sizeof(struct dom_sid));
s = str;
@@ -159,13 +163,18 @@ char *dom_sid_string(TALLOC_CTX *memctx, const struct dom_sid *dom_sid)
uint32_t ia;
char *buf;
- if (dom_sid == NULL) {
+ if (dom_sid == NULL
+ || dom_sid->num_auths < 0
+ || dom_sid->num_auths > SID_SUB_AUTHS) {
return NULL;
}
len = 25 + dom_sid->num_auths * 11;
buf = talloc_zero_size(memctx, len);
+ if (buf == NULL) {
+ return NULL;
+ }
ia = (dom_sid->id_auth[5]) +
(dom_sid->id_auth[4] << 8 ) +