fr_tls_log(request, "Failed retrieving certificate");
return -1;
}
- der_ctx.tmp_ctx = talloc_new(ctx);
+ der_ctx = (fr_der_decode_ctx_t) {
+ .tmp_ctx = talloc_new(ctx),
+ .root = attr_der_certificate,
+ };
cert_der = cd = talloc_array(der_ctx.tmp_ctx, uint8_t, der_len);
i2d_X509(cert, &cd);
fr_pair_list_init(&tmp_list);
void *proto_ctx)
{
fr_dbuff_t our_in = FR_DBUFF_TMP(data, data_len);
+ fr_der_decode_ctx_t *der_ctx = proto_ctx;
+ fr_dict_attr_t const *parent = der_ctx->root;
- fr_dict_attr_t const *parent = fr_dict_root(dict_der);
-
- if (unlikely(parent == fr_dict_root(dict_der))) {
+ if (!parent || (parent == fr_dict_root(dict_der))) {
fr_strerror_printf_push("Invalid dictionary. DER decoding requires a specific dictionary.");
return -1;
}
* Test points
*/
static int decode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict,
- UNUSED fr_dict_attr_t const *root_da)
+ fr_dict_attr_t const *root_da)
{
fr_der_decode_ctx_t *test_ctx;
test_ctx = talloc_zero(ctx, fr_der_decode_ctx_t);
if (!test_ctx) return -1;
- test_ctx->tmp_ctx = talloc_new(test_ctx);
+ test_ctx->tmp_ctx = talloc_new(test_ctx);
+ test_ctx->root = root_da;
*out = test_ctx;
typedef struct {
TALLOC_CTX *tmp_ctx; //!< ctx under which temporary data will be allocated
+ fr_dict_attr_t const *root; //!< where to start decoding from
} fr_der_decode_ctx_t;
static inline fr_der_attr_flags_t const *fr_der_attr_flags(fr_dict_attr_t const *da)