summaryrefslogtreecommitdiffstats
path: root/crypto/heimdal/lib/krb5/mk_safe.c
diff options
context:
space:
mode:
authorassar <assar@FreeBSD.org>2001-06-21 02:12:07 +0000
committerassar <assar@FreeBSD.org>2001-06-21 02:12:07 +0000
commit0c8fa354358381b3f1b92598e7f1b46f8cf744cc (patch)
treeed28ffb73cc0ae48a9892dab3f10b09bc36436d5 /crypto/heimdal/lib/krb5/mk_safe.c
parent06c859ecf534f468a52f24a3eb14409d73a4907c (diff)
downloadFreeBSD-src-0c8fa354358381b3f1b92598e7f1b46f8cf744cc.zip
FreeBSD-src-0c8fa354358381b3f1b92598e7f1b46f8cf744cc.tar.gz
import of heimdal 0.3f
Diffstat (limited to 'crypto/heimdal/lib/krb5/mk_safe.c')
-rw-r--r--crypto/heimdal/lib/krb5/mk_safe.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/crypto/heimdal/lib/krb5/mk_safe.c b/crypto/heimdal/lib/krb5/mk_safe.c
index 2803d38..085ebaf 100644
--- a/crypto/heimdal/lib/krb5/mk_safe.c
+++ b/crypto/heimdal/lib/krb5/mk_safe.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997 - 2000 Kungliga Tekniska Högskolan
+ * Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -33,7 +33,7 @@
#include <krb5_locl.h>
-RCSID("$Id: mk_safe.c,v 1.24 2000/08/18 06:48:40 assar Exp $");
+RCSID("$Id: mk_safe.c,v 1.26 2001/05/14 06:14:50 assar Exp $");
krb5_error_code
krb5_mk_safe(krb5_context context,
@@ -48,6 +48,7 @@ krb5_mk_safe(krb5_context context,
KerberosTime sec2;
int usec2;
u_char *buf = NULL;
+ void *tmp;
size_t buf_size;
size_t len;
u_int32_t tmp_seq;
@@ -78,8 +79,10 @@ krb5_mk_safe(krb5_context context,
buf_size = length_KRB_SAFE(&s);
buf = malloc(buf_size + 128); /* add some for checksum */
- if(buf == NULL)
+ if(buf == NULL) {
+ krb5_set_error_string (context, "malloc: out of memory");
return ENOMEM;
+ }
ret = encode_KRB_SAFE (buf + buf_size - 1, buf_size, &s, &len);
if (ret) {
free (buf);
@@ -93,6 +96,7 @@ krb5_mk_safe(krb5_context context,
ret = krb5_create_checksum(context,
crypto,
KRB5_KU_KRB_SAFE_CKSUM,
+ 0,
buf + buf_size - len,
len,
&s.cksum);
@@ -103,9 +107,13 @@ krb5_mk_safe(krb5_context context,
}
buf_size = length_KRB_SAFE(&s);
- buf = realloc(buf, buf_size);
- if(buf == NULL)
+ tmp = realloc(buf, buf_size);
+ if(tmp == NULL) {
+ free(buf);
+ krb5_set_error_string (context, "malloc: out of memory");
return ENOMEM;
+ }
+ buf = tmp;
ret = encode_KRB_SAFE (buf + buf_size - 1, buf_size, &s, &len);
free_Checksum (&s.cksum);
@@ -114,6 +122,7 @@ krb5_mk_safe(krb5_context context,
outbuf->data = malloc (len);
if (outbuf->data == NULL) {
free (buf);
+ krb5_set_error_string (context, "malloc: out of memory");
return ENOMEM;
}
memcpy (outbuf->data, buf + buf_size - len, len);
OpenPOWER on IntegriCloud