(krb5_rd_safe): set length before trying to allocate data

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19827 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2007-01-11 02:54:59 +00:00
parent 7405b522a1
commit d52fe4e20a

View File

@@ -184,13 +184,14 @@ krb5_rd_safe(krb5_context context,
if (ret)
goto failure;
outbuf->length = safe.safe_body.user_data.length;
outbuf->data = malloc(outbuf->length);
if (outbuf->data == NULL && outbuf->length != 0) {
ret = ENOMEM;
krb5_set_error_string (context, "malloc: out of memory");
krb5_data_zero(outbuf);
goto failure;
}
outbuf->length = safe.safe_body.user_data.length;
memcpy (outbuf->data, safe.safe_body.user_data.data, outbuf->length);
if ((auth_context->flags &