It may be useful to set a size limit on the context we pass to the decoders to prevent an attacker exploiting a logic bug. In this case we want the decoder to handle the memory allocation failure gracefully.
fr_pair_delete_by_da(&packet->vps, attr_ms_chap_challenge);
fr_pair_delete_by_da(&packet->vps, attr_ms_chap_response);
- challenge = fr_pair_afrom_da(packet, attr_ms_chap_challenge);
- if (!challenge) return 0;
+ MEM(challenge = fr_pair_afrom_da(packet, attr_ms_chap_challenge));
fr_pair_add(request, challenge);
challenge->vp_length = 8;
p[i] = fr_rand();
}
- reply = fr_pair_afrom_da(packet, attr_ms_chap_response);
- if (!reply) {
- return 0;
- }
-
+ MEM(reply = fr_pair_afrom_da(packet, attr_ms_chap_response));
fr_pair_add(request, reply);
reply->vp_length = 50;
reply->vp_octets = p = talloc_array(reply, uint8_t, reply->vp_length);
da = parent;
}
- vp = fr_pair_afrom_da(ctx, da);
- if (!vp) {
- fr_strerror_printf("Failed allocating OID attribute");
- return -(slen);
- }
+ MEM(vp = fr_pair_afrom_da(ctx, da));
/*
* VALUE_PAIRs with no value need a 1 byte value buffer.
goto error;
}
- vp = fr_pair_afrom_da(ctx, attr_freeradius_snmp_type);
- if (!vp) {
- slen = -(slen);
- goto error;
- }
+ MEM(vp = fr_pair_afrom_da(ctx, attr_freeradius_snmp_type));
vp->vp_uint32 = type;
fr_cursor_append(cursor, vp);
* Now add an attribute indicating what the
* SNMP operation was
*/
- vp = fr_pair_afrom_da(request, attr_freeradius_snmp_operation);
- if (!vp) {
- ERROR("Failed allocating SNMP operation attribute");
- return EXIT_FAILURE;
- }
+ MEM(vp = fr_pair_afrom_da(request, attr_freeradius_snmp_operation));
vp->vp_uint32 = (unsigned int)command; /* Commands must match dictionary */
fr_cursor_append(&cursor, vp);
size = total;
if (size > 253) size = 253;
- vp = fr_pair_afrom_da(packet, attr_eap_message);
- if (!vp) {
- fr_pair_list_free(&head);
- return NULL;
- }
+ MEM(vp = fr_pair_afrom_da(packet, attr_eap_message));
fr_pair_value_memcpy(vp, ptr, size, false);
fr_cursor_append(&out, vp);
if (!chbind) return NULL; /* don't produce garbage */
- vp = fr_pair_afrom_da(packet, attr_eap_channel_binding_message);
- if (!vp) return NULL;
+ MEM(vp = fr_pair_afrom_da(packet, attr_eap_channel_binding_message));
fr_pair_value_memcpy(vp, (uint8_t *) chbind, talloc_array_length((uint8_t *)chbind), false);
return vp;
USES_APPLE_DEPRECATED_API
-#define LOG_PREFIX "%s - "
-#define LOG_PREFIX_ARGS handle_config->name
-
#include <freeradius-devel/server/rad_assert.h>
#include <freeradius-devel/ldap/base.h>
for (i = 0; i < self->count; i++) {
if (!self->values[i]->bv_len) continue;
- vp = fr_pair_afrom_da(ctx, map->lhs->tmpl_da);
- rad_assert(vp);
+ MEM(vp = fr_pair_afrom_da(ctx, map->lhs->tmpl_da));
if (fr_pair_value_from_str(vp, self->values[i]->bv_val,
self->values[i]->bv_len, '\0', true) < 0) {
{
VALUE_PAIR *vp;
- vp = fr_pair_afrom_da(ctx, map->lhs->tmpl_da);
- if (!vp) {
- REDEBUG("Out of memory");
- return -1;
- }
+ MEM(vp = fr_pair_afrom_da(ctx, map->lhs->tmpl_da));
vp->op = map->op;
vp->tag = map->lhs->tmpl_tag;
if (fr_pair_value_from_str(vp, answer, -1, '"', false) < 0) {
{
VALUE_PAIR *vp;
- vp = fr_pair_afrom_da(ctx, attr->tmpl_da);
- if (!vp) return NULL;
-
+ MEM(vp = fr_pair_afrom_da(ctx, attr->tmpl_da));
vp->tag = attr->tmpl_tag;
if (fr_value_box_copy(vp, &vp->data, value) < 0) {
rad_assert(map->lhs->tmpl_da); /* We need to know which attribute to create */
rad_assert(map->rhs->tmpl_xlat != NULL);
- n = fr_pair_afrom_da(ctx, map->lhs->tmpl_da);
- if (!n) return -1;
+ MEM(n = fr_pair_afrom_da(ctx, map->lhs->tmpl_da));
/*
* We do the debug printing because xlat_aeval_compiled
rad_assert(tmpl_is_attr(map->lhs));
rad_assert(map->lhs->tmpl_da); /* We need to know which attribute to create */
- n = fr_pair_afrom_da(ctx, map->lhs->tmpl_da);
- if (!n) return -1;
+ MEM(n = fr_pair_afrom_da(ctx, map->lhs->tmpl_da));
str = NULL;
slen = xlat_aeval(request, &str, request, map->rhs->name, NULL, NULL);
rad_assert(tmpl_is_attr(map->lhs));
rad_assert(map->lhs->tmpl_da); /* We need to know which attribute to create */
- n = fr_pair_afrom_da(ctx, map->lhs->tmpl_da);
- if (!n) return -1;
+ MEM(n = fr_pair_afrom_da(ctx, map->lhs->tmpl_da));
if (fr_pair_value_from_str(n, map->rhs->name, -1, '\0', false) < 0) {
rcode = 0;
(void) fr_cursor_init(&to, out);
for (; vp; vp = fr_cursor_current(&from)) {
- n = fr_pair_afrom_da(ctx, map->lhs->tmpl_da);
- if (!n) return -1;
+ MEM(n = fr_pair_afrom_da(ctx, map->lhs->tmpl_da));
if (fr_value_box_cast(n, &n->data,
map->lhs->tmpl_da->type, map->lhs->tmpl_da, &vp->data) < 0) {
rad_assert(map->lhs->tmpl_da);
rad_assert(tmpl_is_attr(map->lhs));
- n = fr_pair_afrom_da(ctx, map->lhs->tmpl_da);
- if (!n) return -1;
+ MEM(n = fr_pair_afrom_da(ctx, map->lhs->tmpl_da));
if (map->lhs->tmpl_da->type == map->rhs->tmpl_value_type) {
if (fr_value_box_copy(n, &n->data, &map->rhs->tmpl_value) < 0) {
return false;
default:
- MEM(0);
return false;
}
}
switch (known_good->vp_length) {
case SHA224_DIGEST_LENGTH:
- out = fr_pair_afrom_da(ctx, attr_sha3_224_password);
+ MEM(out = fr_pair_afrom_da(ctx, attr_sha3_224_password));
fr_pair_value_copy(out, known_good);
return out;
case SHA256_DIGEST_LENGTH:
- out = fr_pair_afrom_da(ctx, attr_sha3_256_password);
+ MEM(out = fr_pair_afrom_da(ctx, attr_sha3_256_password));
fr_pair_value_copy(out, known_good);
return out;
return out;
case SHA512_DIGEST_LENGTH:
- out = fr_pair_afrom_da(ctx, attr_sha3_512_password);
+ MEM(out = fr_pair_afrom_da(ctx, attr_sha3_512_password));
fr_pair_value_copy(out, known_good);
return out;
default:
- out = password_normify(ctx, request, known_good);
+ MEM(out = password_normify(ctx, request, known_good));
if (!out) return NULL;
normalised = password_process_sha3(ctx, request, out);
if (!fr_cond_assert(known_good->da->attr < NUM_ELEMENTS(password_info))) return NULL;
info = &password_info[attr];
- new = fr_pair_afrom_da(ctx, *(info->da));
+ MEM(new = fr_pair_afrom_da(ctx, *(info->da)));
switch ((*(info->da))->type) {
case FR_TYPE_OCTETS:
fr_pair_value_memcpy(new, (uint8_t const *)p, end - p, true);
}
bad_header:
- new = fr_pair_afrom_da(request, def);
+ MEM(new = fr_pair_afrom_da(request, def));
fr_pair_value_bstrncpy(new, p, end - p);
return new;
return -(depth);
}
- vp = fr_pair_afrom_da(request->reply, da);
- if (!vp) return 0;
-
+ MEM(vp = fr_pair_afrom_da(request->reply, da));
vp->vp_uint32 = i;
fr_cursor_prepend(out, vp);
*/
if (map_p->get(request->reply, &data, map_p, snmp_ctx) < 0) goto error;
- vp = fr_pair_afrom_da(request->reply, map_p->da);
- if (!vp) return 0;
+ MEM(vp = fr_pair_afrom_da(request->reply, map_p->da));
fr_value_box_steal(vp, &vp->data, &data);
fr_cursor_append(out, vp);
- vp = fr_pair_afrom_da(request->reply, attr_snmp_type);
- if (!vp) return 0;
+ MEM(vp = fr_pair_afrom_da(request->reply, attr_snmp_type));
vp->vp_uint32 = map_p->type;
fr_cursor_append(out, vp);
}
ssize_t ret;
if (!map_p->set || (map_p->type == FR_FREERADIUS_SNMP_TYPE_OBJECT)) {
- vp = fr_pair_afrom_da(request->reply, attr_snmp_failure);
- if (!vp) return 0;
+ MEM(vp = fr_pair_afrom_da(request->reply, attr_snmp_failure));
vp->vp_uint32 = FR_FREERADIUS_SNMP_FAILURE_VALUE_NOT_WRITABLE;
fr_cursor_append(out, vp);
return 0;
case FR_FREERADIUS_SNMP_FAILURE_VALUE_WRONG_LENGTH:
case FR_FREERADIUS_SNMP_FAILURE_VALUE_WRONG_VALUE:
case FR_FREERADIUS_SNMP_FAILURE_VALUE_INCONSISTENT_VALUE:
- vp = fr_pair_afrom_da(request->reply, attr_snmp_failure);
- if (!vp) break;
-
+ MEM(vp = fr_pair_afrom_da(request->reply, attr_snmp_failure));
vp->vp_uint32 = -(ret);
fr_cursor_append(out, vp);
break;
*out = NULL;
- vp = fr_pair_afrom_da(request, cast);
- if (!vp) return -1;
-
+ MEM(vp = fr_pair_afrom_da(request, cast));
if (tmpl_is_data(vpt)) {
VP_VERIFY(vp);
rad_assert(vp->vp_type == vpt->tmpl_value_type);
RADIUS_LIST_AND_CTX(ctx, head, request, vpt->tmpl_request, vpt->tmpl_list);
- vp = fr_pair_afrom_da(ctx, vpt->tmpl_da);
- if (!vp) {
- REDEBUG("Failed allocating attribute %s", vpt->tmpl_da->name);
- return -1;
- }
+ MEM(vp = fr_pair_afrom_da(ctx, vpt->tmpl_da));
*out = vp;
}
return 0;
continue;
}
- nvp = fr_pair_afrom_da(talloc_parent(vp), vp->da);
- if (!nvp) {
- fr_pair_list_free(&head);
- talloc_free(vpt);
- return -1;
- }
+ MEM(nvp = fr_pair_afrom_da(talloc_parent(vp), vp->da));
nvp->tag = vp->tag;
switch (vp->vp_type) {
/*
* Put the SSL data into an attribute.
*/
- vp = fr_pair_afrom_da(request->state_ctx, attr_tls_session_data);
- if (!vp) {
- RPEDEBUG("Failed allocating &Session-Data");
- return -1;
- }
-
+ MEM(vp = fr_pair_afrom_da(request->state_ctx, attr_tls_session_data));
fr_pair_value_memcpy(vp, tls_session->session_blob, talloc_array_length(tls_session->session_blob), false);
RINDENT();
RDEBUG2("&session-state:%pP", vp);
HEADERS := $(subst src/lib/,,$(wildcard src/lib/util/*.h))
-SRC_CFLAGS := -D_LIBRADIUS -I$(top_builddir)/src
+SRC_CFLAGS := -D_LIBRADIUS -DNO_ASSERT -I$(top_builddir)/src
# System libraries discovered by our top level configure script, links things
# like pthread and the regexp libraries.
#include <freeradius-devel/missing.h>
#include <freeradius-devel/util/fring.h>
-#define MEM(x) do { if (!(x)) { ERROR("%s[%u] OUT OF MEMORY", __FILE__, __LINE__); _fr_exit_now(__FILE__, __LINE__, EXIT_FAILURE); } } while (0)
+#ifdef NO_ASSERT
+# define MEM(x) error "Use of MEM() not allowed in this source file. Deal with memory allocation failure gracefully"
+#else
+# define MEM(x) do { if (!(x)) { ERROR("%s[%u] OUT OF MEMORY", __FILE__, __LINE__); _fr_exit_now(__FILE__, __LINE__, EXIT_FAILURE); } } while (0)
+#endif
typedef enum {
DEBUGGER_STATE_UNKNOWN_NO_PTRACE = -3, //!< We don't have ptrace so can't check.
* @param[in] dl_loader Tree of dynamically loaded libraries, and callbacks.
* @param[in] dl to search for symbols in.
*/
-static void dl_symbol_free(dl_loader_t *dl_loader, dl_t const *dl)
+static int dl_symbol_free(dl_loader_t *dl_loader, dl_t const *dl)
{
dl_symbol_free_t *free;
fr_cursor_t cursor;
if (free->symbol) {
char *sym_name = NULL;
- MEM(sym_name = talloc_typed_asprintf(NULL, "%s_%s", dl->name, free->symbol));
+ sym_name = talloc_typed_asprintf(NULL, "%s_%s", dl->name, free->symbol);
+ if (!sym_name) return -1;
+
sym = dlsym(dl->handle, sym_name);
talloc_free(sym_name);
free->func(dl, sym, free->ctx);
}
+
+ return 0;
}
/** Register a callback to execute when a dl with a particular symbol is first loaded
dl_symbol_init_cb_unregister(dl_loader, symbol, func);
- MEM(n = talloc(dl_loader, dl_symbol_init_t));
+ n = talloc(dl_loader, dl_symbol_init_t);
+ if (!n) return -1;
+
n->priority = priority;
n->symbol = symbol;
n->func = func;
dl_symbol_free_cb_unregister(dl_loader, symbol, func);
- MEM(n = talloc(dl_loader, dl_symbol_free_t));
+ n = talloc(dl_loader, dl_symbol_free_t);
+ if (!n) return -1;
+
n->priority = priority;
n->symbol = symbol;
n->func = func;
* Add the tunneled attributes to the fake request.
*/
- request->packet->vps = fr_pair_afrom_da(fake->packet, attr_eap_message);
+ MEM(request->packet->vps = fr_pair_afrom_da(fake->packet, attr_eap_message));
fr_pair_value_memcpy(request->packet->vps, tlv_eap_payload->vp_octets, tlv_eap_payload->vp_length, false);
RDEBUG2("Got tunneled request");
if (data_len > 65535) return NULL; /* paranoia */
- vp = fr_pair_afrom_da(packet, attr_eap_message);
- if (!vp) {
- return NULL;
- }
-
+ MEM(vp = fr_pair_afrom_da(packet, attr_eap_message));
total = data_len;
if (total > 249) total = 249;
fr_cursor_init(&cursor, &head);
fr_cursor_append(&cursor, vp);
while (total < data_len) {
- vp = fr_pair_afrom_da(packet, attr_eap_message);
- if (!vp) {
- fr_pair_list_free(&head);
- return NULL;
- }
-
+ MEM(vp = fr_pair_afrom_da(packet, attr_eap_message));
fr_pair_value_memcpy(vp, data + total, (data_len - total), false);
total += vp->vp_length;
/*
* Save it for later.
*/
- t->username = fr_pair_afrom_da(t, attr_user_name);
- rad_assert(t->username != NULL);
+ MEM(t->username = fr_pair_afrom_da(t, attr_user_name));
t->username->vp_tainted = true;
fr_pair_value_bstrncpy(t->username, data + 1, data_len - 1);
* EAP-Identity packet.
*/
if ((data[0] == FR_EAP_METHOD_IDENTITY) && (data_len > 1)) {
- t->username = fr_pair_afrom_da(t, attr_user_name);
+ MEM(t->username = fr_pair_afrom_da(t, attr_user_name));
rad_assert(t->username != NULL);
t->username->vp_tainted = true;
/*
* Create & remember a User-Name
*/
- t->username = fr_pair_afrom_da(t, attr_user_name);
- rad_assert(t->username != NULL);
+ MEM(t->username = fr_pair_afrom_da(t, attr_user_name));
t->username->vp_tainted = true;
fr_pair_value_bstrncpy(t->username, vp->vp_octets + 5, vp->vp_length - 5);
return -1;
}
- vp = fr_pair_afrom_da(parent, da);
- if (!vp) {
- fr_strerror_printf("out of memory");
- talloc_free(value);
- return -1;
- }
-
+ MEM(vp = fr_pair_afrom_da(parent, da));
(void) fr_pair_cursor_init(&cursor, &parent->options);
/*
rcode = read_token(state, T_DOUBLE_QUOTED_STRING, MAYBE_SEMICOLON, false);
if (rcode <= 0) return rcode;
- vp = fr_pair_afrom_da(parent, da);
- if (!vp) return -1;
+ MEM(vp = fr_pair_afrom_da(parent, da));
rcode = fr_pair_value_from_str(vp, state->token, state->token_len, '\0', false);
if (rcode < 0) return rcode;
if (info->cmd->type != ISC_FIXED_ADDRESS) continue;
- vp = fr_pair_afrom_da(request->reply->vps, attr_your_ip_address);
- if (!vp) return -1;
+ MEM(vp = fr_pair_afrom_da(request->reply->vps, attr_your_ip_address));
rcode = fr_value_box_copy(vp, &(vp->data), info->argv[0]);
if (rcode < 0) return rcode;
for (fr_cursor_init(&cursor, out), value = head;
value;
fr_cursor_append(&cursor, vp), value = value->next) {
- vp = fr_pair_afrom_da(ctx, map->lhs->tmpl_da);
- if (!vp) {
- error:
- talloc_free(*out);
- return -1;
- }
+ MEM(vp = fr_pair_afrom_da(ctx, map->lhs->tmpl_da));
vp->op = map->op;
if (fr_value_box_steal(vp, &vp->data, value) < 0) {
RPEDEBUG("Copying data to attribute failed");
talloc_free(vp);
- goto error;
+ talloc_free(*out);
+ return -1;
}
}
return 0;
continue;
}
- if (!(vp = fr_pair_afrom_da(ctx, dst->tmpl_da))) {
- ERROR("Failed to create attribute %s", ckey);
- talloc_free(dst);
- continue;
- }
-
+ MEM(vp = fr_pair_afrom_da(ctx, dst->tmpl_da));
talloc_free(dst);
vp->op = op;
continue;
}
- vp = fr_pair_afrom_da(ctx, dst->tmpl_da);
+ MEM(vp = fr_pair_afrom_da(ctx, dst->tmpl_da));
talloc_free(dst);
- if (!vp) {
- ERROR("%s - Failed to create attribute %s:%s", funcname, list_name, s1);
- continue;
- }
-
vp->op = op;
if (fr_pair_value_from_str(vp, s2, -1, '\0', false) < 0) {
attr[1] = 6;
memcpy(attr + 2, &c->inst->parent->proxy_state, 4);
- vp = fr_pair_afrom_da(u, attr_proxy_state);
+ MEM(vp = fr_pair_afrom_da(u, attr_proxy_state));
fr_pair_value_memcpy(vp, attr + 2, 4, true);
fr_pair_add(&u->extra, vp);
if (msg) {
VALUE_PAIR *vp;
- vp = fr_pair_afrom_da(u, attr_message_authenticator);
+ MEM(vp = fr_pair_afrom_da(u, attr_message_authenticator));
fr_pair_value_memcpy(vp, msg + 2, 16, true);
fr_pair_add(&u->extra, vp);
* - Number of VALUE_PAIRs processed.
* - -1 on unrecoverable error.
*/
-static int rest_decode_post(UNUSED rlm_rest_t const *instance, UNUSED rlm_rest_section_t const *section,
+static int rest_decode_post(rlm_rest_t const *instance, UNUSED rlm_rest_section_t const *section,
REQUEST *request, void *handle, char *raw, size_t rawlen)
{
+ rlm_rest_t const *inst = instance;
rlm_rest_handle_t *randle = handle;
CURL *candle = randle->candle;
rad_assert(expanded);
- vp = fr_pair_afrom_da(ctx, da);
+ MEM(vp = fr_pair_afrom_da(ctx, da));
if (!vp) {
REDEBUG("Failed creating valuepair");
talloc_free(expanded);
* - #VALUE_PAIR just created.
* - NULL on error.
*/
-static VALUE_PAIR *json_pair_alloc_leaf(UNUSED rlm_rest_t const *instance, UNUSED rlm_rest_section_t const *section,
+static VALUE_PAIR *json_pair_alloc_leaf(rlm_rest_t const *instance, UNUSED rlm_rest_section_t const *section,
TALLOC_CTX *ctx, REQUEST *request,
fr_dict_attr_t const *da, json_flags_t *flags, json_object *leaf)
{
- char const *value;
- char *expanded = NULL;
- int ret;
+ rlm_rest_t const *inst = instance;
+ char const *value;
+ char *expanded = NULL;
+ int ret;
- VALUE_PAIR *vp;
+ VALUE_PAIR *vp;
- fr_value_box_t src;
+ fr_value_box_t src;
if (fr_json_object_is_type(leaf, json_type_null)) {
RDEBUG3("Got null value for attribute \"%s\" (skipping)", da->name);
return NULL;
}
- vp = fr_pair_afrom_da(ctx, da);
+ MEM(vp = fr_pair_afrom_da(ctx, da));
if (!vp) {
RWDEBUG("Failed creating valuepair for attribute \"%s\" (skipping)", da->name);
talloc_free(expanded);
RDEBUG2("SIM auth vector %i", i);
RINDENT();
- vp = fr_pair_afrom_da(request, attr_eap_aka_sim_rand);
+ MEM(vp = fr_pair_afrom_da(request, attr_eap_aka_sim_rand));
fr_pair_value_memsteal(vp, vec->sim.rand, true);
RDEBUG2("&control:%pP", vp);
fr_cursor_append(&cursor, vp);
- vp = fr_pair_afrom_da(request, attr_eap_aka_sim_sres);
+ MEM(vp = fr_pair_afrom_da(request, attr_eap_aka_sim_sres));
fr_pair_value_memsteal(vp, vec->sim.sres, true);
RDEBUG2("&control:%pP", vp);
fr_cursor_append(&cursor, vp);
- vp = fr_pair_afrom_da(request, attr_eap_aka_sim_kc);
+ MEM(vp = fr_pair_afrom_da(request, attr_eap_aka_sim_kc));
fr_pair_value_memsteal(vp, vec->sim.kc, true);
RDEBUG2("&control:%pP", vp);
fr_cursor_append(&cursor, vp);
RDEBUG2("UMTS auth vector %i", i);
RINDENT();
- vp = fr_pair_afrom_da(request, attr_eap_aka_sim_rand);
+ MEM(vp = fr_pair_afrom_da(request, attr_eap_aka_sim_rand));
fr_pair_value_memsteal(vp, vec->umts.rand, true);
RDEBUG2("&control:%pP", vp);
fr_cursor_append(&cursor, vp);
- vp = fr_pair_afrom_da(request, attr_eap_aka_sim_xres);
+ MEM(vp = fr_pair_afrom_da(request, attr_eap_aka_sim_xres));
fr_pair_value_memsteal(vp, vec->umts.xres, true);
RDEBUG2("&control:%pP", vp);
fr_cursor_append(&cursor, vp);
- vp = fr_pair_afrom_da(request, attr_eap_aka_sim_ck);
+ MEM(vp = fr_pair_afrom_da(request, attr_eap_aka_sim_ck));
fr_pair_value_memsteal(vp, vec->umts.ck, true);
RDEBUG2("&control:%pP", vp);
fr_cursor_append(&cursor, vp);
- vp = fr_pair_afrom_da(request, attr_eap_aka_sim_ik);
+ MEM(vp = fr_pair_afrom_da(request, attr_eap_aka_sim_ik));
fr_pair_value_memsteal(vp, vec->umts.ik, true);
RDEBUG2("&control:%pP", vp);
fr_cursor_append(&cursor, vp);
- vp = fr_pair_afrom_da(request, attr_eap_aka_sim_autn);
+ MEM(vp = fr_pair_afrom_da(request, attr_eap_aka_sim_autn));
fr_pair_value_memsteal(vp, vec->umts.authn, true);
RDEBUG2("&control:%pP", vp);
fr_cursor_append(&cursor, vp);
RDEBUG2("SoH adding NAP marker to DHCP reply");
/* client probe; send "NAP" in the reply */
- vp = fr_pair_afrom_da(request->reply, attr_dhcp_vendor);
- p = talloc_array(vp, uint8_t, 5);
+ MEM(vp = fr_pair_afrom_da(request->reply, attr_dhcp_vendor));
+ MEM(p = talloc_array(vp, uint8_t, 5));
p[0] = 220;
p[1] = 3;
p[4] = 'N';
da = fr_dict_attr_by_name(dict_radius, buffer);
if (!da) continue;
- vp = fr_pair_afrom_da(request->reply, da);
- if (!vp) return RLM_MODULE_FAIL;
-
+ MEM(vp = fr_pair_afrom_da(request->reply, da));
vp->vp_uint64 = local_stats[i];
fr_cursor_append(&cursor, vp);
goto nothing;
}
- cast = fr_pair_afrom_da(request, da);
- if (!cast) goto nothing;
+ MEM(cast = fr_pair_afrom_da(request, da));
memcpy(&(cast->data), input + offset, dict_attr_sizes[type][0]);
raw.c \
udp.c
-SRC_CFLAGS := -I$(top_builddir)/src
+SRC_CFLAGS := -I$(top_builddir)/src -DNO_ASSERT
TGT_LDLIBS := $(PCAP_LIBS)
TGT_LDFLAGS := $(PCAP_LDFLAGS)
TGT_PREREQS := libfreeradius-util.a
decode.c \
encode.c
+SRC_CFLAGS := -DNO_ASSERT
TGT_PREREQS := libfreeradius-util.a
p += 2;
slen = decode_value(ctx, cursor, dict, parent, p, element_len , decoder_ctx);
if (slen < 0) return slen;
- p += slen;
+ p += slen;
}
return data_len;
SOURCES := ethernet.c
+SRC_CFLAGS := -DNO_ASSERT
TGT_PREREQS := $(LIBFREERADIUS_SERVER) libfreeradius-io.a libfreeradius-util.a
packet.c \
tcp.c
-SRC_CFLAGS := -D_LIBRADIUS -I$(top_builddir)/src
+SRC_CFLAGS := -D_LIBRADIUS -DNO_ASSERT -I$(top_builddir)/src
TGT_PREREQS := libfreeradius-util.a
TARGET := libfreeradius-tacacs.a
+SRC_CFLAGS := -DNO_ASSERT
SOURCES := base.c decode.c encode.c
}
seq_no = vp->vp_uint8 + 1; /* we catch client 255 on ingress */
- MEM(vp = fr_pair_afrom_da(packet, vp->da));
+ vp = fr_pair_afrom_da(packet, vp->da);
+ if (!vp) {
+ oom:
+ fr_strerror_printf("Out of memory");
+ return -1;
+ }
vp->vp_uint8 = vminor;
fr_pair_add(&packet->vps, vp);
type = tacacs_type(original);
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_packet_type));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_packet_type);
+ if (!vp) goto oom;
vp->vp_uint8 = type;
fr_pair_add(&packet->vps, vp);
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_sequence_number));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_sequence_number);
+ if (!vp) goto oom;
vp->vp_uint8 = seq_no;
fr_pair_add(&packet->vps, vp);
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_session_id));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_session_id);
+ if (!vp) goto oom;
vp->vp_uint32 = tacacs_session_id(original);
fr_pair_add(&packet->vps, vp);
return -1;
}
- MEM(vp = fr_pair_afrom_da(ctx, da));
+ vp = fr_pair_afrom_da(ctx, da);
+ if (!vp) {
+ fr_strerror_printf("Out of Memory");
+ return -1;
+ }
fr_pair_value_bstrncpy(vp, p, field_len);
p += field_len;
remaining = ntohl(pkt->hdr.length);
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_version_minor));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_version_minor);
+ if (!vp) {
+ oom:
+ fr_strerror_printf("Out of Memory");
+ return -1;
+ }
vp->vp_uint8 = pkt->hdr.ver.minor;
fr_cursor_append(&cursor, vp);
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_packet_type));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_packet_type);
+ if (!vp) goto oom;
vp->vp_uint8 = pkt->hdr.type;
fr_cursor_append(&cursor, vp);
packet->code = pkt->hdr.type;
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_sequence_number));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_sequence_number);
+ if (!vp) goto oom;
vp->vp_uint8 = pkt->hdr.seq_no;
fr_cursor_append(&cursor, vp);
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_session_id));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_session_id);
+ if (!vp) goto oom;
vp->vp_uint32 = ntohl(pkt->hdr.session_id);
fr_cursor_append(&cursor, vp);
session_id = vp->vp_uint32;
/*
* Decode 4 octets of various flags.
*/
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_action));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_action);
+ if (!vp) goto oom;
vp->vp_uint8 = pkt->authen.start.action;
fr_cursor_append(&cursor, vp);
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_privilege_level));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_privilege_level);
+ if (!vp) goto oom;
vp->vp_uint8 = pkt->authen.start.priv_lvl;
fr_cursor_append(&cursor, vp);
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_authentication_type));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_authentication_type);
+ if (!vp) goto oom;
vp->vp_uint8 = pkt->authen.start.authen_type;
fr_cursor_append(&cursor, vp);
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_authentication_service));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_authentication_service);
+ if (!vp) goto oom;
vp->vp_uint8 = pkt->authen.start.authen_service;
fr_cursor_append(&cursor, vp);
/*
* Decode 4 octets of various flags.
*/
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_authentication_method));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_authentication_method);
+ if (!vp) goto oom;
vp->vp_uint8 = pkt->author.req.authen_method;
fr_cursor_append(&cursor, vp);
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_privilege_level));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_privilege_level);
+ if (!vp) goto oom;
vp->vp_uint8 = pkt->author.req.priv_lvl;
fr_cursor_append(&cursor, vp);
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_authentication_type));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_authentication_type);
+ if (!vp) goto oom;
vp->vp_uint8 = pkt->author.req.authen_type;
fr_cursor_append(&cursor, vp);
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_authentication_service));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_authentication_service);
+ if (!vp) goto oom;
vp->vp_uint8 = pkt->author.req.authen_service;
fr_cursor_append(&cursor, vp);
/*
* Decode 8 octets of various fields.
*/
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_accounting_flags));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_accounting_flags);
+ if (!vp) goto oom;
vp->vp_uint8 = pkt->acct.req.flags;
fr_cursor_append(&cursor, vp);
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_authentication_method));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_authentication_method);
+ if (!vp) goto oom;
vp->vp_uint8 = pkt->acct.req.authen_method;
fr_cursor_append(&cursor, vp);
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_privilege_level));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_privilege_level);
+ if (!vp) goto oom;
vp->vp_uint8 = pkt->acct.req.priv_lvl;
fr_cursor_append(&cursor, vp);
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_authentication_type));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_authentication_type);
+ if (!vp) goto oom;
vp->vp_uint8 = pkt->acct.req.authen_type;
fr_cursor_append(&cursor, vp);
- MEM(vp = fr_pair_afrom_da(packet, attr_tacacs_authentication_service));
+ vp = fr_pair_afrom_da(packet, attr_tacacs_authentication_service);
+ if (!vp) goto oom;
vp->vp_uint8 = pkt->acct.req.authen_service;
fr_cursor_append(&cursor, vp);
SOURCES := vqp.c base.c
-SRC_CFLAGS := -I$(top_builddir)/src
+SRC_CFLAGS := -I$(top_builddir)/src -DNO_ASSERT
TGT_PREREQS := libfreeradius-util.a
fr_cursor_init(&cursor, &packet->vps);
- MEM(vp = fr_pair_afrom_da(packet, attr_packet_type));
+ vp = fr_pair_afrom_da(packet, attr_packet_type);
+ if (!vp) {
+ oom:
+ fr_strerror_printf("Out of Memory");
+ return -1;
+ }
vp->vp_uint32 = packet->data[1];
vp->vp_tainted = true;
DEBUG2("&%pP", vp);
fr_cursor_append(&cursor, vp);
- MEM(vp = fr_pair_afrom_da(packet, attr_error_code));
+ vp = fr_pair_afrom_da(packet, attr_error_code);
+ if (!vp) goto oom;
vp->vp_uint32 = packet->data[2];
vp->vp_tainted = true;
DEBUG2("&%pP", vp);
fr_cursor_append(&cursor, vp);
- MEM(vp = fr_pair_afrom_da(packet, attr_sequence_number));
+ vp = fr_pair_afrom_da(packet, attr_sequence_number);
+ if (!vp) goto oom;
vp->vp_uint32 = packet->id; /* already set by vqp_recv */
vp->vp_tainted = true;
DEBUG2("&%pP", vp);