* Add if (_x->da) (void) talloc_get_type_abort(_x->da, DICT_ATTR);
* to the macro below when dictionaries are talloced.
*/
-# define VERIFY_VP(_x) fr_verify_vp(_x)
-# define VERIFY_LIST(_x) fr_verify_list(NULL, _x)
+# define VERIFY_VP(_x) fr_verify_vp(__FILE__, __LINE__, _x)
+# define VERIFY_LIST(_x) fr_verify_list(__FILE__, __LINE__, NULL, _x)
# define VERIFY_PACKET(_x) (void) talloc_get_type_abort(_x, RADIUS_PACKET)
#else
/*
void fr_fault_set_log_fd(int fd);
#ifdef WITH_VERIFY_PTR
-void fr_verify_vp(VALUE_PAIR const *vp);
-void fr_verify_list(TALLOC_CTX *expected, VALUE_PAIR *vps);
+void fr_verify_vp(char const *file, int line, VALUE_PAIR const *vp);
+void fr_verify_list(char const *file, int line, TALLOC_CTX *expected, VALUE_PAIR *vps);
#endif
/* rbtree.c */
#define REQUEST_MAX_REGEX (8)
#if defined(WITH_VERIFY_PTR)
-# define VERIFY_REQUEST(_x) verify_request(_x)
+# define VERIFY_REQUEST(_x) verify_request(__FILE__, __LINE__, _x)
#else
/*
* Even if were building without WITH_VERIFY_PTR
size_t argv_buflen, char *argv_buf);
void rad_regcapture(REQUEST *request, int compare, char const *value,
regmatch_t rxmatch[]);
-void verify_request(REQUEST *request); /* only for special debug builds */
+void verify_request(char const *file, int line, REQUEST *request); /* only for special debug builds */
/* client.c */
RADCLIENT_LIST *clients_init(CONF_SECTION *cs);
/*
* Verify a VALUE_PAIR
*/
-inline void fr_verify_vp(VALUE_PAIR const *vp)
+inline void fr_verify_vp(char const *file, int line, VALUE_PAIR const *vp)
{
(void) talloc_get_type_abort(vp, VALUE_PAIR);
size_t len;
if (!talloc_get_type(vp->data.ptr, uint8_t)) {
- fprintf(stderr, "Type check failed for attribute \"%s\"", vp->da->name);
+ fprintf(stderr, "CONSISTENCY CHECK FAILED %s[%u]: Attribute \"%s\" value buffer type should be "
+ "uint8_t but is %s", file, line, vp->da->name, talloc_get_name(vp->data.ptr));
(void) talloc_get_type_abort(vp->data.ptr, uint8_t);
}
len = talloc_array_length(vp->vp_octets);
if (vp->length > len) {
- fprintf(stderr, "VALUE_PAIR length %zu does not equal uint8_t buffer length %zu", vp->length, len);
+ fprintf(stderr, "CONSISTENCY CHECK FAILED %s[%u]: VALUE_PAIR length %zu does not equal uint8_t "
+ "value buffer length %zu", file, line, vp->length, len);
fr_assert(0);
fr_exit_now(1);
}
size_t len;
if (!talloc_get_type(vp->data.ptr, char)) {
- fprintf(stderr, "Type check failed for attribute \"%s\"", vp->da->name);
+ fprintf(stderr, "CONSISTENCY CHECK FAILED %s[%u]: Attribute \"%s\" value buffer type should be "
+ "char but is %s", file, line, vp->da->name, talloc_get_name(vp->data.ptr));
(void) talloc_get_type_abort(vp->data.ptr, char);
}
len = (talloc_array_length(vp->vp_strvalue) - 1);
if (vp->length > len) {
- fprintf(stderr, "VALUE_PAIR %s length %zu is too small for char buffer length %zu",
- vp->da->name, vp->length, len);
+ fprintf(stderr, "CONSISTENCY CHECK FAILED %s[%u]: VALUE_PAIR %s length %zu is too small for "
+ "char buffer length %zu", file, line, vp->da->name, vp->length, len);
fr_assert(0);
fr_exit_now(1);
}
if (vp->vp_strvalue[vp->length] != '\0') {
- fprintf(stderr, "VALUE_PAIR %s buffer not \\0 terminated", vp->da->name);
+ fprintf(stderr, "CONSISTENCY CHECK FAILED %s[%u]: VALUE_PAIR %s buffer not \\0 terminated",
+ file, line, vp->da->name);
fr_assert(0);
fr_exit_now(1);
}
/*
* Verify a pair list
*/
-void fr_verify_list(TALLOC_CTX *expected, VALUE_PAIR *vps)
+void fr_verify_list(char const *file, int line, TALLOC_CTX *expected, VALUE_PAIR *vps)
{
vp_cursor_t cursor;
VALUE_PAIR *vp;
parent = talloc_parent(vp);
if (expected && (parent != expected)) {
- fprintf(stderr, "Expected VALUE_PAIR (%s) to be parented by %p (%s), "
- "but parented by %p (%s)",
- vp->da->name,
+ fprintf(stderr, "CONSISTENCY CHECK FAILED %s[%u]: Expected VALUE_PAIR (%s) to be parented "
+ "by %p (%s), but parented by %p (%s)",
+ file, line, vp->da->name,
expected, talloc_get_name(expected),
parent, parent ? talloc_get_name(parent) : "NULL");
/*
* Verify a packet.
*/
-static void verify_packet(REQUEST *request, RADIUS_PACKET *packet)
+static void verify_packet(char const *file, int line, REQUEST *request, RADIUS_PACKET *packet)
{
TALLOC_CTX *parent;
parent = talloc_parent(packet);
if (parent != request) {
- ERROR("Expected RADIUS_PACKET to be parented by %p (%s), "
- "but parented by %p (%s)",
- request, talloc_get_name(request),
+ ERROR("CONSISTENCY CHECK FAILED %s[%u]: Expected RADIUS_PACKET to be parented by %p (%s), "
+ "but parented by %p (%s)", file, line, request, talloc_get_name(request),
parent, parent ? talloc_get_name(parent) : "NULL");
fr_log_talloc_report(packet);
if (!packet->vps) return;
#ifdef WITH_VERIFY_PTR
- fr_verify_list(packet, packet->vps);
+ fr_verify_list(file, line, packet, packet->vps);
#endif
}
/*
* Catch horrible talloc errors.
*/
-void verify_request(REQUEST *request)
+void verify_request(char const *file, int line, REQUEST *request)
{
if (!request) return;
(void) talloc_get_type_abort(request, REQUEST);
#ifdef WITH_VERIFY_PTR
- fr_verify_list(request, request->config_items);
+ fr_verify_list(file, line, request, request->config_items);
#endif
- if (request->packet) verify_packet(request, request->packet);
- if (request->reply) verify_packet(request, request->reply);
+ if (request->packet) verify_packet(file, line, request, request->packet);
+ if (request->reply) verify_packet(file, line, request, request->reply);
#ifdef WITH_PROXY
- if (request->proxy) verify_packet(request, request->proxy);
- if (request->proxy_reply) verify_packet(request, request->proxy_reply);
+ if (request->proxy) verify_packet(file, line, request, request->proxy);
+ if (request->proxy_reply) verify_packet(file, line, request, request->proxy_reply);
#endif
#ifdef WITH_COA
rad_assert(parent == request);
- verify_request(request->coa);
+ verify_request(file, line, request->coa);
}
#endif
}