summaryrefslogtreecommitdiffstats
path: root/crypto/heimdal/lib/krb5/mk_safe.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/heimdal/lib/krb5/mk_safe.c')
-rw-r--r--crypto/heimdal/lib/krb5/mk_safe.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/crypto/heimdal/lib/krb5/mk_safe.c b/crypto/heimdal/lib/krb5/mk_safe.c
index 4d848a6..2803d38 100644
--- a/crypto/heimdal/lib/krb5/mk_safe.c
+++ b/crypto/heimdal/lib/krb5/mk_safe.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1998, 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1997 - 2000 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.20 1999/12/02 17:05:11 joda Exp $");
+RCSID("$Id: mk_safe.c,v 1.24 2000/08/18 06:48:40 assar Exp $");
krb5_error_code
krb5_mk_safe(krb5_context context,
@@ -50,7 +50,7 @@ krb5_mk_safe(krb5_context context,
u_char *buf = NULL;
size_t buf_size;
size_t len;
- int tmp_seq;
+ u_int32_t tmp_seq;
krb5_crypto crypto;
s.pvno = 5;
@@ -64,7 +64,7 @@ krb5_mk_safe(krb5_context context,
usec2 = usec2;
s.safe_body.usec = &usec2;
if (auth_context->flags & KRB5_AUTH_CONTEXT_DO_SEQUENCE) {
- tmp_seq = ++auth_context->local_seqnumber;
+ tmp_seq = auth_context->local_seqnumber;
s.safe_body.seq_number = &tmp_seq;
} else
s.safe_body.seq_number = NULL;
@@ -76,13 +76,20 @@ krb5_mk_safe(krb5_context context,
s.cksum.checksum.data = NULL;
s.cksum.checksum.length = 0;
-
buf_size = length_KRB_SAFE(&s);
buf = malloc(buf_size + 128); /* add some for checksum */
if(buf == NULL)
return ENOMEM;
ret = encode_KRB_SAFE (buf + buf_size - 1, buf_size, &s, &len);
+ if (ret) {
+ free (buf);
+ return ret;
+ }
ret = krb5_crypto_init(context, auth_context->keyblock, 0, &crypto);
+ if (ret) {
+ free (buf);
+ return ret;
+ }
ret = krb5_create_checksum(context,
crypto,
KRB5_KU_KRB_SAFE_CKSUM,
@@ -111,5 +118,8 @@ krb5_mk_safe(krb5_context context,
}
memcpy (outbuf->data, buf + buf_size - len, len);
free (buf);
+ if (auth_context->flags & KRB5_AUTH_CONTEXT_DO_SEQUENCE)
+ auth_context->local_seqnumber =
+ (auth_context->local_seqnumber + 1) & 0xFFFFFFFF;
return 0;
}
OpenPOWER on IntegriCloud