* is generated.
*/
fr_strerror_const("fuzz"); /* allocate the pools */
- fr_strerror(); /* clears the message, leaves the pools */
+ fr_strerror_clear(); /* clears the message, leaves the pools */
/*
* Setup our own internal atexit handler
tp->func(ctx, &vps, buf, len, decode_ctx);
talloc_free(ctx);
- fr_strerror(); /* Clear any undrained errors */
/*
* Clear error messages from the run. Clearing these
* keeps malloc/free balanced, which helps to avoid the
* fuzzers leak heuristics from firing.
*/
- fr_strerror_const(NULL);
+ fr_strerror_clear();
return 0;
}
stats.rejected++;
}
- fr_strerror(); /* Clear strerror buffer */
+ fr_strerror_clear(); /* Clear strerror buffer */
/*
* If we had an expected response code, check to see if the
"Failed to initialize the dictionaries");
return 1;
}
- fr_strerror(); /* Clear the error buffer */
+ fr_strerror_clear(); /* Clear the error buffer */
/*
* Get the request type
/*
* Clear the libfreeradius error buffer.
*/
- fr_strerror();
+ fr_strerror_clear();
/*
* Prevent anything from modifying the dictionaries
* we don't inteferere with the onexit() handler.
*/
if (!rad_suid_is_down_permanent() && (fr_get_lsan_state() == 1)) rad_suid_up();
- fr_strerror(); /* clear error buffer */
+ fr_strerror_clear(); /* clear error buffer */
return ret;
}
return 1;
}
- fr_strerror(); /* Clear out any non-fatal errors */
+ fr_strerror_clear(); /* Clear out any non-fatal errors */
if (conf->list_attributes) {
conf->list_da_num = rs_build_dict_list(conf->list_da, NUM_ELEMENTS(conf->list_da),
}
/* Clear any irrelevant errors */
- fr_strerror();
+ fr_strerror_clear();
}
/*
return slen;
}
- fr_strerror(); /* Clear pending errors */
+ fr_strerror_clear(); /* Clear pending errors */
/*
* SNMP requests the leaf under the OID with .0.
static int radsnmp_send_recv(radsnmp_conf_t *conf, int fd)
{
- fr_strerror();
+ fr_strerror_clear();
#define NEXT_LINE(_line, _buffer) \
{ \
fr_perror("radsnmp");
fr_exit_now(EXIT_FAILURE);
}
- fr_strerror(); /* Clear the error buffer */
+ fr_strerror_clear(); /* Clear the error buffer */
/*
* Get the request type
PERROR("Failed to initialize the dictionaries");
return 1;
}
- fr_strerror(); /* Clear the error buffer */
+ fr_strerror_clear(); /* Clear the error buffer */
/*
* Be safe.
/*
* Clear any spurious errors
*/
- fr_strerror();
+ fr_strerror_clear();
ASAN_UNPOISON_MEMORY_REGION(to_dec_end, COMMAND_OUTPUT_MAX - slen);
/*
/*
* Clear any spurious errors
*/
- fr_strerror();
+ fr_strerror_clear();
ASAN_UNPOISON_MEMORY_REGION(to_dec_end, COMMAND_OUTPUT_MAX - slen);
/*
/*
* Clear any spurious errors
*/
- fr_strerror();
+ fr_strerror_clear();
fr_pair_list_free(&head);
/*
* Clear any spurious errors
*/
- fr_strerror();
+ fr_strerror_clear();
CLEAR_TEST_POINT(cc);
fr_assert(out_len >= (size_t)*pipelined);
- fr_strerror(); /* Clear any outstanding errors */
+ fr_strerror_clear(); /* Clear any outstanding errors */
if ((size_t) *pipelined > out_len) {
for (i = 0; i < (size_t)*pipelined; i++) {
/*
* Clear pre-existing errors.
*/
- fr_strerror();
+ fr_strerror_clear();
if (dl_module->common->onload) {
int ret;
if (fr_sbuff_out(NULL, &oid, name) > 0) {
fr_dict_attr_t *da_unknown;
- fr_strerror(); /* Clear out any existing errors */
+ fr_strerror_clear(); /* Clear out any existing errors */
/*
* If it's numeric and not a known attribute
*head = NULL;
- fr_strerror(); /* Clear error buffer */
+ fr_strerror_clear(); /* Clear error buffer */
if (xlat_tokenize_literal(ctx, head, flags,
&our_in, false, p_rules, t_rules) < 0) return -fr_sbuff_used(&our_in);
if (!flags) flags = &tmp_flags;
*head = NULL;
- fr_strerror(); /* Clear error buffer */
+ fr_strerror_clear(); /* Clear error buffer */
if (xlat_tokenize_literal(ctx, head, flags,
&our_in, false, p_rules, t_rules) < 0) return -fr_sbuff_used(&our_in);
ret = _dict_from_file(ctx, dir, argv[1], fn, line);
if ((ret == -2) && (argv[0][8] == '-')) {
- fr_strerror_printf(NULL); /* delete all errors */
+ fr_strerror_clear(); /* delete all errors */
ret = 0;
}
*/
#if defined(RTLD_DEEPBIND) && !defined(__SANITIZE_ADDRESS__)
flags |= RTLD_DEEPBIND;
- fr_strerror(); /* clear error buffer */
+ fr_strerror_clear(); /* clear error buffer */
#endif
/*
char *ctx, *paths, *path;
char *p;
- fr_strerror();
+ fr_strerror_clear();
ctx = paths = talloc_typed_strdup(NULL, search_path);
while ((path = strsep(&paths, ":")) != NULL) {
* Clear any errors we may have produced in the
* capabilities check.
*/
- fr_strerror();
+ fr_strerror_clear();
#endif
return 0;
}
* Clear any existing log messages
*/
if (!fmt) {
- talloc_free_children(buffer->pool_a);
- talloc_free_children(buffer->pool_b);
- fr_dlist_clear(&buffer->entries);
+ fr_strerror_clear();
return NULL;
}
*
* @hidecallergraph
*/
-static inline CC_HINT(always_inline) fr_log_entry_t *strerror_const(char const *msg)
+static inline CC_HINT(always_inline) CC_HINT(nonnull) fr_log_entry_t *strerror_const(char const *msg)
{
fr_log_entry_t *entry;
fr_log_buffer_t *buffer;
buffer = fr_strerror_init();
if (unlikely(!buffer)) return NULL;
- /*
- * Clear any existing log messages
- */
- if (!msg) {
- fr_dlist_clear(&buffer->entries);
- talloc_free_children(buffer->pool_a);
- talloc_free_children(buffer->pool_b);
- return NULL;
- }
-
entry = talloc(pool_alt(buffer), fr_log_entry_t);
if (unlikely(!entry)) {
fr_perror("Failed allocating memory for libradius error buffer");
*
* @hidecallergraph
*/
-static fr_log_entry_t *strerror_const_push(fr_log_buffer_t *buffer, char const *msg)
+static CC_HINT(always_inline) CC_HINT(nonnull)
+fr_log_entry_t *strerror_const_push(fr_log_buffer_t *buffer, char const *msg)
{
fr_log_entry_t *entry;
- if (!msg) return NULL;
-
/*
* Address pathological case where we could leak memory
* if only a combination of fr_strerror and
return entry->msg;
}
+/** Clears all pending messages from the talloc pools
+ *
+ */
+void fr_strerror_clear(void)
+{
+ fr_log_buffer_t *buffer;
+
+ if (unlikely(!fr_strerror_buffer)) return;
+
+ buffer = fr_strerror_init();
+ fr_dlist_clear(&buffer->entries);
+ talloc_free_children(buffer->pool_a);
+ talloc_free_children(buffer->pool_b);
+}
+
/** Get the last library error marker
*
* @param[out] subject The subject string the error relates to.
* @{
*/
/** @hidecallergraph */
-void fr_strerror_printf(char const *fmt, ...) CC_HINT(format (printf, 1, 2));
+void fr_strerror_printf(char const *fmt, ...) CC_HINT(nonnull) CC_HINT(format (printf, 1, 2));
/** @hidecallergraph */
-void fr_strerror_printf_push(char const *fmt, ...) CC_HINT(format (printf, 1, 2));
+void fr_strerror_printf_push(char const *fmt, ...) CC_HINT(nonnull) CC_HINT(format (printf, 1, 2));
/** @hidecallergraph */
-void fr_strerror_printf_push_head(char const *fmt, ...) CC_HINT(format (printf, 1, 2));
+void fr_strerror_printf_push_head(char const *fmt, ...) CC_HINT(nonnull) CC_HINT(format (printf, 1, 2));
/** @} */
/** @name Add an error string with marker to the thread local error stack
* @{
*/
/** @hidecallergraph */
-void fr_strerror_marker_printf(char const *subject, size_t offset, char const *fmt, ...) CC_HINT(format (printf, 3, 4));
+void fr_strerror_marker_printf(char const *subject, size_t offset, char const *fmt, ...) CC_HINT(nonnull) CC_HINT(format (printf, 3, 4));
/** @hidecallergraph */
-void fr_strerror_marker_printf_push(char const *subject, size_t offset, char const *fmt, ...) CC_HINT(format (printf, 3, 4));
+void fr_strerror_marker_printf_push(char const *subject, size_t offset, char const *fmt, ...) CC_HINT(nonnull) CC_HINT(format (printf, 3, 4));
/** @hidecallergraph */
-void fr_strerror_marker_printf_push_head(char const *subject, size_t offset, char const *fmt, ...) CC_HINT(format (printf, 3, 4));
+void fr_strerror_marker_printf_push_head(char const *subject, size_t offset, char const *fmt, ...) CC_HINT(nonnull) CC_HINT(format (printf, 3, 4));
/** @} */
/** @name Add a const error string to the thread local error stack
* @{
*/
/** @hidecallergraph */
-void fr_strerror_const(char const *msg);
+void fr_strerror_const(char const *msg) CC_HINT(nonnull);
/** @hidecallergraph */
-void fr_strerror_const_push(char const *msg);
+void fr_strerror_const_push(char const *msg) CC_HINT(nonnull);
/** @hidecallergraph */
-void fr_strerror_const_push_head(char const *msg);
+void fr_strerror_const_push_head(char const *msg) CC_HINT(nonnull);
/** @} */
/** @name Retrieve errors from the thread local error stack
* @{
*/
/** @hidecallergraph */
-char const *fr_strerror(void);
+char const *fr_strerror(void) CC_HINT(warn_unused_result);
/** @hidecallergraph */
-char const *fr_strerror_marker(char const **subject, size_t *offset);
+void fr_strerror_clear(void);
+
+/** @hidecallergraph */
+char const *fr_strerror_marker(char const **subject, size_t *offset) CC_HINT(nonnull);
/** @hidecallergraph */
char const *fr_strerror_peek(void);
/** @hidecallergraph */
-char const *fr_strerror_marker_peek(char const **subject, size_t *offset);
+char const *fr_strerror_marker_peek(char const **subject, size_t *offset) CC_HINT(nonnull);
/** @hidecallergraph */
char const *fr_strerror_pop(void);
/** @hidecallergraph */
-char const *fr_strerror_marker_pop(char const **subject, size_t *offset);
+char const *fr_strerror_marker_pop(char const **subject, size_t *offset) CC_HINT(nonnull);
/** @hidecallergraph */
void fr_perror(char const *, ...) CC_HINT(format (printf, 1, 2));
uint64_t rate;
fr_strerror_const("pre-allocate buffers");
- fr_strerror();
+ fr_strerror_clear();
start = fr_time();
for (i = 0; i < 100000; i++) {
fr_strerror_printf("I am a test %u string %u %s", i, i, "benchmark");
- fr_strerror(); /* Clear */
+ fr_strerror_clear(); /* Clear */
}
stop = fr_time();
uint64_t rate;
fr_strerror_const("pre-allocate buffers");
- fr_strerror();
+ fr_strerror_clear();
start = fr_time();
for (i = 0; i < 100000; i++) {
fr_strerror_const("I am a test string");
- fr_strerror(); /* Clear */
+ fr_strerror_clear(); /* Clear */
}
stop = fr_time();
*reply = fr_dhcpv4_udp_packet_recv(sockfd);
if (!*reply) {
if (errno == EAGAIN) {
- fr_strerror(); /* clear error */
+ fr_strerror_clear(); /* clear error */
ERROR("Timed out waiting for reply");
} else {
ERROR("Error receiving reply");
fr_perror("dhcpclient");
fr_exit(EXIT_FAILURE);
}
- fr_strerror(); /* Clear the error buffer */
+ fr_strerror_clear(); /* Clear the error buffer */
/*
* Initialise the DHCPv4 library
fr_perror("sync_touch");
fr_exit_now(EXIT_FAILURE);
}
- fr_strerror(); /* Clear the error buffer */
+ fr_strerror_clear(); /* Clear the error buffer */
fr_set_signal(SIGPIPE, rs_signal_stop);
fr_set_signal(SIGINT, rs_signal_stop);