even on success to avoid a memory leak.
* util_cksum.c (kg_checksum_channel_bindings): Fix memory leak by
not allocating cksum->contents unless we have to return a
zero-filled one.
* k5unseal.c (kg_unseal_v1): Fix memorly leak by not allocating
md5cksum.contents.
* k5seal.c (make_seal_token_v1): Fix memory leak by not allocating
md5cksum.contents.
* accept_sec_context.c (krb5_gss_accept_sec_context): Only free
ap_req.data if it was allocated by kg2_parse_token(), otherwise we
lose very badly trying to free the middle of a potentially
malloc()'ed block, possibly coredumping.
git-svn-id: svn://anonsvn.mit.edu/krb5/branches/marc-3des@10927
dc483132-0cff-0310-8789-
dd5450dbe970
Mon Sep 21 00:32:28 1998 Tom Yu <tlyu@mit.edu>
+ * accept_sec_context.c (krb5_gss_accept_sec_context): Free authdat
+ even on success to avoid a memory leak.
+
+ * util_cksum.c (kg_checksum_channel_bindings): Fix memory leak by
+ not allocating cksum->contents unless we have to return a
+ zero-filled one.
+
+ * k5unseal.c (kg_unseal_v1): Fix memorly leak by not allocating
+ md5cksum.contents.
+
+ * k5seal.c (make_seal_token_v1): Fix memory leak by not allocating
+ md5cksum.contents.
+
* accept_sec_context.c (krb5_gss_accept_sec_context): Only free
ap_req.data if it was allocated by kg2_parse_token(), otherwise we
lose very badly trying to free the middle of a potentially
/* finally! */
+ if (authdat)
+ krb5_free_authenticator(context, authdat);
*minor_status = 0;
return(GSS_S_COMPLETE);
/* pad the plaintext, encrypt if needed, and stick it in the token */
- /* initialize the the cksum and allocate the contents buffer */
+ /* initialize the the cksum */
if (code = krb5_c_checksum_length(context, CKSUMTYPE_RSA_MD5, &sumlen))
return(code);
md5cksum.checksum_type = CKSUMTYPE_RSA_MD5;
md5cksum.length = sumlen;
- if ((md5cksum.contents = (krb5_octet *) xmalloc(md5cksum.length)) == NULL)
- return(ENOMEM);
-
if (toktype == KG_TOK_SEAL_MSG) {
unsigned char *plain;
unsigned char pad;
if (!bigend || encrypt) {
if ((plain = (unsigned char *) xmalloc(tmsglen)) == NULL) {
- xfree(md5cksum.contents);
xfree(t);
return(ENOMEM);
}
if ((code = kg_make_confounder(context, enc, plain))) {
xfree(plain);
- xfree(md5cksum.contents);
xfree(t);
return(code);
}
tmsglen))) {
if (plain)
xfree(plain);
- xfree(md5cksum.contents);
xfree(t);
return(code);
}
(char *) xmalloc(8 + (bigend ? text->length : tmsglen)))) {
if (plain)
xfree(plain);
- xfree(md5cksum.contents);
xfree(t);
return(ENOMEM);
}
if (code) {
if (plain)
xfree(plain);
- xfree(md5cksum.contents);
xfree(t);
return(code);
memcpy(ptr+14+cksum_size, plain, tmsglen);
/* compute the checksum */
if (! (data_ptr = (char *) xmalloc(8 + text->length))) {
- xfree(md5cksum.contents);
xfree(t);
return(ENOMEM);
}
&plaind, &md5cksum);
xfree(data_ptr);
if (code) {
- xfree(md5cksum.contents);
xfree(t);
return(code);
}
/* compute the checksum of the message */
- /* initialize the the cksum and allocate the contents buffer */
+ /* initialize the the cksum */
if (code = krb5_c_checksum_length(context, CKSUMTYPE_RSA_MD5, &sumlen))
return(code);
md5cksum.checksum_type = CKSUMTYPE_RSA_MD5;
md5cksum.length = sumlen;
- if ((md5cksum.contents = (krb5_octet *) xmalloc(md5cksum.length)) == NULL) {
- if (sealalg != 0xffff)
- xfree(plain);
- *minor_status = ENOMEM;
- return(GSS_S_FAILURE);
- }
switch (signalg) {
case 0:
if (! (data_ptr = (void *)
xmalloc(8 + (ctx->big_endian ? token.length : plainlen)))) {
- xfree(md5cksum.contents);
if (sealalg != 0xffff)
xfree(plain);
if (toktype == KG_TOK_SEAL_MSG)
xfree(data_ptr);
if (code) {
- xfree(md5cksum.contents);
if (toktype == KG_TOK_SEAL_MSG)
xfree(token.value);
*minor_status = code;
plaind.length = 8 + sizeof(ctx->seed) +
(ctx->big_endian ? token.length : plainlen);
plaind.data = data_ptr;
+ xfree(md5cksum.contents);
code = krb5_c_make_checksum(context, md5cksum.checksum_type, 0, 0,
&plaind, &md5cksum);
xfree(data_ptr);
if (code) {
- xfree(md5cksum.contents);
if (sealalg == 0)
xfree(plain);
if (toktype == KG_TOK_SEAL_MSG)
krb5_data plaind;
krb5_error_code code;
- /* initialize the the cksum and allocate the contents buffer */
+ /* initialize the the cksum */
if (code = krb5_c_checksum_length(context, CKSUMTYPE_RSA_MD5, &sumlen))
return(code);
cksum->checksum_type = CKSUMTYPE_RSA_MD5;
cksum->length = sumlen;
- if ((cksum->contents = (krb5_octet *) xmalloc(cksum->length)) == NULL) {
- return(ENOMEM);
- }
/* generate a buffer full of zeros if no cb specified */
if (cb == GSS_C_NO_CHANNEL_BINDINGS) {
- memset(cksum->contents, '\0', cksum->length);
- return(0);
+ if ((cksum->contents = (krb5_octet *) xmalloc(cksum->length)) == NULL) {
+ return(ENOMEM);
+ }
+ memset(cksum->contents, '\0', cksum->length);
+ return(0);
}
/* create the buffer to checksum into */