dont entrust sprintf to encode binary packets
This commit is contained in:
@@ -123,21 +123,26 @@ make_result (krb5_data *data,
|
|||||||
uint16_t result_code,
|
uint16_t result_code,
|
||||||
const char *expl)
|
const char *expl)
|
||||||
{
|
{
|
||||||
char *str;
|
krb5_error_code ret;
|
||||||
krb5_data_zero (data);
|
krb5_storage *sp;
|
||||||
|
|
||||||
data->length = asprintf (&str,
|
sp = krb5_storage_emem();
|
||||||
"%c%c%s",
|
if (sp == NULL) goto out;
|
||||||
(result_code >> 8) & 0xFF,
|
ret = krb5_store_uint32(sp, result_code);
|
||||||
result_code & 0xFF,
|
if (ret) goto out;
|
||||||
expl);
|
ret = krb5_store_stringz(sp, expl);
|
||||||
|
if (ret) goto out;
|
||||||
|
ret = krb5_storage_to_data(sp, data);
|
||||||
|
if (ret) goto out;
|
||||||
|
krb5_storage_free(sp);
|
||||||
|
|
||||||
if (str == NULL) {
|
|
||||||
krb5_warnx (context, "Out of memory generating error reply");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
data->data = str;
|
|
||||||
return 0;
|
return 0;
|
||||||
|
out:
|
||||||
|
if (sp)
|
||||||
|
krb5_storage_free(sp);
|
||||||
|
|
||||||
|
krb5_warnx (context, "Out of memory generating error reply");
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user