summaryrefslogtreecommitdiff
path: root/source3/libads/krb5_setpw.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2003-02-04 23:44:05 +0000
committerJeremy Allison <jra@samba.org>2003-02-04 23:44:05 +0000
commit0701e642f2d78ff572f7d7dcdf9b5c59750c6c30 (patch)
treefe1f80898ffcae98c2e9c7bac686278a42a96c61 /source3/libads/krb5_setpw.c
parentbfcdd6eed3d3e9dca7ef45793562703a951ead25 (diff)
downloadsamba-0701e642f2d78ff572f7d7dcdf9b5c59750c6c30.tar.gz
samba-0701e642f2d78ff572f7d7dcdf9b5c59750c6c30.tar.bz2
samba-0701e642f2d78ff572f7d7dcdf9b5c59750c6c30.zip
Mem alloc failure checks.
Jeremy. (This used to be commit 4e33e3f37fd548b9b1ed3c84f673a853b0dc4818)
Diffstat (limited to 'source3/libads/krb5_setpw.c')
-rw-r--r--source3/libads/krb5_setpw.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/source3/libads/krb5_setpw.c b/source3/libads/krb5_setpw.c
index 73d370d75f..087b0e9a71 100644
--- a/source3/libads/krb5_setpw.c
+++ b/source3/libads/krb5_setpw.c
@@ -139,13 +139,19 @@ static krb5_error_code build_setpw_request(krb5_context context,
}
packet->data = (char *)malloc(ap_req->length + cipherpw.length + 6);
+ if (!packet->data)
+ return -1;
/* see the RFC for details */
p = ((char *)packet->data) + 2;
- RSSVAL(p, 0, 0xff80); p += 2;
- RSSVAL(p, 0, ap_req->length); p += 2;
- memcpy(p, ap_req->data, ap_req->length); p += ap_req->length;
- memcpy(p, cipherpw.data, cipherpw.length); p += cipherpw.length;
+ RSSVAL(p, 0, 0xff80);
+ p += 2;
+ RSSVAL(p, 0, ap_req->length);
+ p += 2;
+ memcpy(p, ap_req->data, ap_req->length);
+ p += ap_req->length;
+ memcpy(p, cipherpw.data, cipherpw.length);
+ p += cipherpw.length;
packet->length = PTR_DIFF(p,packet->data);
RSSVAL(packet->data, 0, packet->length);
@@ -397,6 +403,17 @@ ADS_STATUS krb5_set_password(const char *kdc_host, const char *princ, const char
chpw_rep.length = 1500;
chpw_rep.data = (char *) malloc(chpw_rep.length);
+ if (!chpw_rep.data) {
+ close(sock);
+ free(ap_req.data);
+ krb5_free_creds(context, credsp);
+ krb5_free_principal(context, creds.client);
+ krb5_free_principal(context, principal);
+ krb5_free_context(context);
+ DEBUG(1,("send of chpw failed (%s)\n", strerror(errno)));
+ errno = ENOMEM;
+ return ADS_ERROR_SYSTEM(errno);
+ }
ret = read(sock, chpw_rep.data, chpw_rep.length);
if (ret < 0) {