(gssapi_krb5_verify_8003_checksum): check size of input
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11532 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -100,56 +100,56 @@ gssapi_krb5_create_8003_checksum (
|
|||||||
const krb5_data *fwd_data,
|
const krb5_data *fwd_data,
|
||||||
Checksum *result)
|
Checksum *result)
|
||||||
{
|
{
|
||||||
u_char *p;
|
u_char *p;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* see rfc1964 (section 1.1.1 (Initial Token), and the checksum value
|
* see rfc1964 (section 1.1.1 (Initial Token), and the checksum value
|
||||||
* field's format) */
|
* field's format) */
|
||||||
result->cksumtype = 0x8003;
|
result->cksumtype = 0x8003;
|
||||||
if (fwd_data->length > 0 && (flags & GSS_C_DELEG_FLAG))
|
if (fwd_data->length > 0 && (flags & GSS_C_DELEG_FLAG))
|
||||||
result->checksum.length = 24 + 4 + fwd_data->length;
|
result->checksum.length = 24 + 4 + fwd_data->length;
|
||||||
else
|
else
|
||||||
result->checksum.length = 24;
|
result->checksum.length = 24;
|
||||||
result->checksum.data = malloc (result->checksum.length);
|
result->checksum.data = malloc (result->checksum.length);
|
||||||
if (result->checksum.data == NULL) {
|
if (result->checksum.data == NULL) {
|
||||||
*minor_status = ENOMEM;
|
*minor_status = ENOMEM;
|
||||||
return GSS_S_FAILURE;
|
return GSS_S_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = result->checksum.data;
|
p = result->checksum.data;
|
||||||
encode_om_uint32 (16, p);
|
encode_om_uint32 (16, p);
|
||||||
p += 4;
|
p += 4;
|
||||||
if (input_chan_bindings == GSS_C_NO_CHANNEL_BINDINGS) {
|
if (input_chan_bindings == GSS_C_NO_CHANNEL_BINDINGS) {
|
||||||
memset (p, 0, 16);
|
memset (p, 0, 16);
|
||||||
} else {
|
} else {
|
||||||
hash_input_chan_bindings (input_chan_bindings, p);
|
hash_input_chan_bindings (input_chan_bindings, p);
|
||||||
}
|
}
|
||||||
p += 16;
|
p += 16;
|
||||||
encode_om_uint32 (flags, p);
|
encode_om_uint32 (flags, p);
|
||||||
p += 4;
|
p += 4;
|
||||||
|
|
||||||
if (fwd_data->length > 0 && (flags & GSS_C_DELEG_FLAG)) {
|
if (fwd_data->length > 0 && (flags & GSS_C_DELEG_FLAG)) {
|
||||||
#if 0
|
#if 0
|
||||||
u_char *tmp;
|
u_char *tmp;
|
||||||
|
|
||||||
result->checksum.length = 28 + fwd_data->length;
|
result->checksum.length = 28 + fwd_data->length;
|
||||||
tmp = realloc(result->checksum.data, result->checksum.length);
|
tmp = realloc(result->checksum.data, result->checksum.length);
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
result->checksum.data = tmp;
|
result->checksum.data = tmp;
|
||||||
|
|
||||||
p = (u_char*)result->checksum.data + 24;
|
p = (u_char*)result->checksum.data + 24;
|
||||||
#endif
|
#endif
|
||||||
*p++ = (1 >> 0) & 0xFF; /* DlgOpt */ /* == 1 */
|
*p++ = (1 >> 0) & 0xFF; /* DlgOpt */ /* == 1 */
|
||||||
*p++ = (1 >> 8) & 0xFF; /* DlgOpt */ /* == 0 */
|
*p++ = (1 >> 8) & 0xFF; /* DlgOpt */ /* == 0 */
|
||||||
*p++ = (fwd_data->length >> 0) & 0xFF; /* Dlgth */
|
*p++ = (fwd_data->length >> 0) & 0xFF; /* Dlgth */
|
||||||
*p++ = (fwd_data->length >> 8) & 0xFF; /* Dlgth */
|
*p++ = (fwd_data->length >> 8) & 0xFF; /* Dlgth */
|
||||||
memcpy(p, (unsigned char *) fwd_data->data, fwd_data->length);
|
memcpy(p, (unsigned char *) fwd_data->data, fwd_data->length);
|
||||||
|
|
||||||
p += fwd_data->length;
|
p += fwd_data->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GSS_S_COMPLETE;
|
return GSS_S_COMPLETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -172,7 +172,7 @@ gssapi_krb5_verify_8003_checksum(
|
|||||||
static unsigned char zeros[16];
|
static unsigned char zeros[16];
|
||||||
|
|
||||||
/* XXX should handle checksums > 24 bytes */
|
/* XXX should handle checksums > 24 bytes */
|
||||||
if(cksum->cksumtype != 0x8003) {
|
if(cksum->cksumtype != 0x8003 || cksum->checksum.length < 24) {
|
||||||
*minor_status = 0;
|
*minor_status = 0;
|
||||||
return GSS_S_BAD_BINDINGS;
|
return GSS_S_BAD_BINDINGS;
|
||||||
}
|
}
|
||||||
@@ -201,27 +201,33 @@ gssapi_krb5_verify_8003_checksum(
|
|||||||
p += sizeof(hash);
|
p += sizeof(hash);
|
||||||
|
|
||||||
decode_om_uint32(p, flags);
|
decode_om_uint32(p, flags);
|
||||||
|
p += 4;
|
||||||
|
|
||||||
if (cksum->checksum.length > 24 && (*flags & GSS_C_DELEG_FLAG)) {
|
if (cksum->checksum.length > 24 && (*flags & GSS_C_DELEG_FLAG)) {
|
||||||
|
if(cksum->checksum.length < 28) {
|
||||||
|
*minor_status = 0;
|
||||||
|
return GSS_S_BAD_BINDINGS;
|
||||||
|
}
|
||||||
|
|
||||||
p += 4;
|
DlgOpt = (p[0] << 0) | (p[1] << 8);
|
||||||
|
p += 2;
|
||||||
DlgOpt = (p[0] << 0) | (p[1] << 8 );
|
if (DlgOpt != 1) {
|
||||||
if (DlgOpt != 1) {
|
*minor_status = 0;
|
||||||
*minor_status = 0;
|
return GSS_S_BAD_BINDINGS;
|
||||||
return GSS_S_BAD_BINDINGS;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
p += 2;
|
|
||||||
fwd_data->length = (p[0] << 0) | (p[1] << 8);
|
|
||||||
fwd_data->data = malloc(fwd_data->length);
|
|
||||||
if (fwd_data->data == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
p += 2;
|
fwd_data->length = (p[0] << 0) | (p[1] << 8);
|
||||||
memcpy(fwd_data->data, p, fwd_data->length);
|
p += 2;
|
||||||
|
if(cksum->checksum.length < 28 + fwd_data->length) {
|
||||||
|
*minor_status = 0;
|
||||||
|
return GSS_S_BAD_BINDINGS;
|
||||||
|
}
|
||||||
|
fwd_data->data = malloc(fwd_data->length);
|
||||||
|
if (fwd_data->data == NULL) {
|
||||||
|
*minor_status = ENOMEM;
|
||||||
|
return GSS_S_FAILURE;
|
||||||
|
}
|
||||||
|
memcpy(fwd_data->data, p, fwd_data->length);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GSS_S_COMPLETE;
|
return GSS_S_COMPLETE;
|
||||||
|
@@ -100,56 +100,56 @@ gssapi_krb5_create_8003_checksum (
|
|||||||
const krb5_data *fwd_data,
|
const krb5_data *fwd_data,
|
||||||
Checksum *result)
|
Checksum *result)
|
||||||
{
|
{
|
||||||
u_char *p;
|
u_char *p;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* see rfc1964 (section 1.1.1 (Initial Token), and the checksum value
|
* see rfc1964 (section 1.1.1 (Initial Token), and the checksum value
|
||||||
* field's format) */
|
* field's format) */
|
||||||
result->cksumtype = 0x8003;
|
result->cksumtype = 0x8003;
|
||||||
if (fwd_data->length > 0 && (flags & GSS_C_DELEG_FLAG))
|
if (fwd_data->length > 0 && (flags & GSS_C_DELEG_FLAG))
|
||||||
result->checksum.length = 24 + 4 + fwd_data->length;
|
result->checksum.length = 24 + 4 + fwd_data->length;
|
||||||
else
|
else
|
||||||
result->checksum.length = 24;
|
result->checksum.length = 24;
|
||||||
result->checksum.data = malloc (result->checksum.length);
|
result->checksum.data = malloc (result->checksum.length);
|
||||||
if (result->checksum.data == NULL) {
|
if (result->checksum.data == NULL) {
|
||||||
*minor_status = ENOMEM;
|
*minor_status = ENOMEM;
|
||||||
return GSS_S_FAILURE;
|
return GSS_S_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = result->checksum.data;
|
p = result->checksum.data;
|
||||||
encode_om_uint32 (16, p);
|
encode_om_uint32 (16, p);
|
||||||
p += 4;
|
p += 4;
|
||||||
if (input_chan_bindings == GSS_C_NO_CHANNEL_BINDINGS) {
|
if (input_chan_bindings == GSS_C_NO_CHANNEL_BINDINGS) {
|
||||||
memset (p, 0, 16);
|
memset (p, 0, 16);
|
||||||
} else {
|
} else {
|
||||||
hash_input_chan_bindings (input_chan_bindings, p);
|
hash_input_chan_bindings (input_chan_bindings, p);
|
||||||
}
|
}
|
||||||
p += 16;
|
p += 16;
|
||||||
encode_om_uint32 (flags, p);
|
encode_om_uint32 (flags, p);
|
||||||
p += 4;
|
p += 4;
|
||||||
|
|
||||||
if (fwd_data->length > 0 && (flags & GSS_C_DELEG_FLAG)) {
|
if (fwd_data->length > 0 && (flags & GSS_C_DELEG_FLAG)) {
|
||||||
#if 0
|
#if 0
|
||||||
u_char *tmp;
|
u_char *tmp;
|
||||||
|
|
||||||
result->checksum.length = 28 + fwd_data->length;
|
result->checksum.length = 28 + fwd_data->length;
|
||||||
tmp = realloc(result->checksum.data, result->checksum.length);
|
tmp = realloc(result->checksum.data, result->checksum.length);
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
result->checksum.data = tmp;
|
result->checksum.data = tmp;
|
||||||
|
|
||||||
p = (u_char*)result->checksum.data + 24;
|
p = (u_char*)result->checksum.data + 24;
|
||||||
#endif
|
#endif
|
||||||
*p++ = (1 >> 0) & 0xFF; /* DlgOpt */ /* == 1 */
|
*p++ = (1 >> 0) & 0xFF; /* DlgOpt */ /* == 1 */
|
||||||
*p++ = (1 >> 8) & 0xFF; /* DlgOpt */ /* == 0 */
|
*p++ = (1 >> 8) & 0xFF; /* DlgOpt */ /* == 0 */
|
||||||
*p++ = (fwd_data->length >> 0) & 0xFF; /* Dlgth */
|
*p++ = (fwd_data->length >> 0) & 0xFF; /* Dlgth */
|
||||||
*p++ = (fwd_data->length >> 8) & 0xFF; /* Dlgth */
|
*p++ = (fwd_data->length >> 8) & 0xFF; /* Dlgth */
|
||||||
memcpy(p, (unsigned char *) fwd_data->data, fwd_data->length);
|
memcpy(p, (unsigned char *) fwd_data->data, fwd_data->length);
|
||||||
|
|
||||||
p += fwd_data->length;
|
p += fwd_data->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GSS_S_COMPLETE;
|
return GSS_S_COMPLETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -172,7 +172,7 @@ gssapi_krb5_verify_8003_checksum(
|
|||||||
static unsigned char zeros[16];
|
static unsigned char zeros[16];
|
||||||
|
|
||||||
/* XXX should handle checksums > 24 bytes */
|
/* XXX should handle checksums > 24 bytes */
|
||||||
if(cksum->cksumtype != 0x8003) {
|
if(cksum->cksumtype != 0x8003 || cksum->checksum.length < 24) {
|
||||||
*minor_status = 0;
|
*minor_status = 0;
|
||||||
return GSS_S_BAD_BINDINGS;
|
return GSS_S_BAD_BINDINGS;
|
||||||
}
|
}
|
||||||
@@ -201,27 +201,33 @@ gssapi_krb5_verify_8003_checksum(
|
|||||||
p += sizeof(hash);
|
p += sizeof(hash);
|
||||||
|
|
||||||
decode_om_uint32(p, flags);
|
decode_om_uint32(p, flags);
|
||||||
|
p += 4;
|
||||||
|
|
||||||
if (cksum->checksum.length > 24 && (*flags & GSS_C_DELEG_FLAG)) {
|
if (cksum->checksum.length > 24 && (*flags & GSS_C_DELEG_FLAG)) {
|
||||||
|
if(cksum->checksum.length < 28) {
|
||||||
|
*minor_status = 0;
|
||||||
|
return GSS_S_BAD_BINDINGS;
|
||||||
|
}
|
||||||
|
|
||||||
p += 4;
|
DlgOpt = (p[0] << 0) | (p[1] << 8);
|
||||||
|
p += 2;
|
||||||
DlgOpt = (p[0] << 0) | (p[1] << 8 );
|
if (DlgOpt != 1) {
|
||||||
if (DlgOpt != 1) {
|
*minor_status = 0;
|
||||||
*minor_status = 0;
|
return GSS_S_BAD_BINDINGS;
|
||||||
return GSS_S_BAD_BINDINGS;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
p += 2;
|
|
||||||
fwd_data->length = (p[0] << 0) | (p[1] << 8);
|
|
||||||
fwd_data->data = malloc(fwd_data->length);
|
|
||||||
if (fwd_data->data == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
p += 2;
|
fwd_data->length = (p[0] << 0) | (p[1] << 8);
|
||||||
memcpy(fwd_data->data, p, fwd_data->length);
|
p += 2;
|
||||||
|
if(cksum->checksum.length < 28 + fwd_data->length) {
|
||||||
|
*minor_status = 0;
|
||||||
|
return GSS_S_BAD_BINDINGS;
|
||||||
|
}
|
||||||
|
fwd_data->data = malloc(fwd_data->length);
|
||||||
|
if (fwd_data->data == NULL) {
|
||||||
|
*minor_status = ENOMEM;
|
||||||
|
return GSS_S_FAILURE;
|
||||||
|
}
|
||||||
|
memcpy(fwd_data->data, p, fwd_data->length);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GSS_S_COMPLETE;
|
return GSS_S_COMPLETE;
|
||||||
|
Reference in New Issue
Block a user