From: Arran Cudbard-Bell Date: Fri, 11 Dec 2020 16:27:12 +0000 (-0700) Subject: Convert fr_strerror_printf calls to fr_strerror_const as the latter is significantly... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6422cf53555eaaebccb460a220716148f26a092;p=thirdparty%2Ffreeradius-server.git Convert fr_strerror_printf calls to fr_strerror_const as the latter is significantly faster --- diff --git a/src/bin/radict.c b/src/bin/radict.c index ef7e5fda181..3ea2b71e834 100644 --- a/src/bin/radict.c +++ b/src/bin/radict.c @@ -113,7 +113,7 @@ static int load_dicts(char const *dict_dir) */ if (ret == 0) { if (dict_end >= (dicts + (NUM_ELEMENTS(dicts)))) { - fr_strerror_printf("Reached maximum number of dictionaries"); + fr_strerror_const("Reached maximum number of dictionaries"); goto error; } diff --git a/src/bin/radiusd.c b/src/bin/radiusd.c index bceb4187064..e15c5bc0d04 100644 --- a/src/bin/radiusd.c +++ b/src/bin/radiusd.c @@ -118,7 +118,7 @@ static int talloc_config_set(main_config_t *config) talloc_free(null_child); if (talloc_set_memlimit(null_ctx, config->talloc_memory_limit) < 0) { - fr_strerror_printf("Failed applying memory limit"); + fr_strerror_const("Failed applying memory limit"); return -1; } } diff --git a/src/bin/radsnmp.c b/src/bin/radsnmp.c index a99738ed034..53e32d8d720 100644 --- a/src/bin/radsnmp.c +++ b/src/bin/radsnmp.c @@ -248,7 +248,7 @@ static ssize_t radsnmp_pair_from_oid(TALLOC_CTX *ctx, radsnmp_conf_t *conf, fr_c */ index_attr = fr_dict_attr_child_by_num(parent, 0); if (!index_attr) { - fr_strerror_printf("Unknown OID component: No index attribute at this level"); + fr_strerror_const("Unknown OID component: No index attribute at this level"); break; } @@ -262,7 +262,7 @@ static ssize_t radsnmp_pair_from_oid(TALLOC_CTX *ctx, radsnmp_conf_t *conf, fr_c */ parent = fr_dict_attr_child_by_num(parent, 1); if (!parent) { - fr_strerror_printf("Unknown OID component: No entry attribute at this level"); + fr_strerror_const("Unknown OID component: No entry attribute at this level"); break; } @@ -346,7 +346,7 @@ static ssize_t radsnmp_pair_from_oid(TALLOC_CTX *ctx, radsnmp_conf_t *conf, fr_c } if (da->type == FR_TYPE_TLV) { - fr_strerror_printf("TLVs cannot hold values"); + fr_strerror_const("TLVs cannot hold values"); return -(slen); } @@ -414,7 +414,7 @@ static int radsnmp_get_response(int fd, slen = snprintf(oid_buff, sizeof(oid_buff), "%u.", parent->attr); if (is_truncated((size_t)slen, sizeof(oid_buff))) { oob: - fr_strerror_printf("OID Buffer too small"); + fr_strerror_const("OID Buffer too small"); return -1; } p += slen; @@ -534,7 +534,7 @@ static int radsnmp_get_response(int fd, */ slen = fr_value_box_print(&FR_SBUFF_OUT(value_buff, sizeof(value_buff)), &vp->data, NULL); if (slen < 0) { - fr_strerror_printf("Insufficient fixed value buffer"); + fr_strerror_const("Insufficient fixed value buffer"); return -1; } io_vector[4].iov_base = value_buff; diff --git a/src/bin/unit_test_attribute.c b/src/bin/unit_test_attribute.c index 64a5857129b..f7d6a59d8b7 100644 --- a/src/bin/unit_test_attribute.c +++ b/src/bin/unit_test_attribute.c @@ -485,7 +485,7 @@ static ssize_t hex_to_bin(uint8_t *out, size_t outlen, char *in, size_t inlen) char *c1, *c2; if (out_p >= out_end) { - fr_strerror_printf("Would overflow output buffer"); + fr_strerror_const("Would overflow output buffer"); return -(p - in); } @@ -557,7 +557,7 @@ static ssize_t encode_data(char *p, uint8_t *output, size_t outlen) slen = hex_to_bin(output, outlen, p, strlen(p)); if (slen <= 0) { - fr_strerror_printf_push("Empty hex string"); + fr_strerror_const_push("Empty hex string"); return slen; } @@ -902,7 +902,7 @@ static int dictionary_load_common(command_result_t *result, command_file_ctx_t * fr_dict_t *dict; if (in[0] == '\0') { - fr_strerror_printf("Missing dictionary name"); + fr_strerror_const("Missing dictionary name"); RETURN_PARSE_ERROR(0); } @@ -1045,7 +1045,7 @@ static size_t command_normalise_attribute(command_result_t *result, command_file talloc_list_free(&head); if (slen < 0) { - fr_strerror_printf("Encoder output would overflow output buffer"); + fr_strerror_const("Encoder output would overflow output buffer"); RETURN_OK_WITH_ERROR(); } @@ -1092,7 +1092,7 @@ static size_t command_radmin_add(command_result_t *result, command_file_ctx_t *c p = strchr(in, ':'); if (!p) { - fr_strerror_printf("no ':name' specified"); + fr_strerror_const("no ':name' specified"); RETURN_PARSE_ERROR(0); } @@ -1125,7 +1125,7 @@ static size_t command_radmin_add(command_result_t *result, command_file_ctx_t *c table->read_only = true; if (fr_command_add(table, &command_head, NULL, NULL, table) < 0) { - fr_strerror_printf_push("ERROR: Failed adding command"); + fr_strerror_const_push("ERROR: Failed adding command"); RETURN_OK_WITH_ERROR(); } @@ -1155,7 +1155,7 @@ static size_t command_radmin_tab(command_result_t *result, command_file_ctx_t *c memcpy(&argv, &info.argv, sizeof(argv)); /* const issues */ info.argc = fr_dict_str_to_argv(in, argv, CMD_MAX_ARGV); if (info.argc <= 0) { - fr_strerror_printf("Failed splitting input"); + fr_strerror_const("Failed splitting input"); RETURN_PARSE_ERROR(-(info.argc)); } @@ -1164,7 +1164,7 @@ static size_t command_radmin_tab(command_result_t *result, command_file_ctx_t *c len = snprintf(p, end - p, "%d - ", num_expansions); if (is_truncated(len, end - p)) { oob: - fr_strerror_printf("Out of output buffer space"); + fr_strerror_const("Out of output buffer space"); RETURN_COMMAND_ERROR(); } p += len; @@ -1199,7 +1199,7 @@ static size_t command_condition_normalise(command_result_t *result, command_file cs = cf_section_alloc(NULL, NULL, "if", "condition"); if (!cs) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); RETURN_COMMAND_ERROR(); } cf_filename_set(cs, cc->filename); @@ -1240,7 +1240,7 @@ static size_t command_count(command_result_t *result, command_file_ctx_t *cc, len = snprintf(data, COMMAND_OUTPUT_MAX, "%u", cc->test_count); if (is_truncated(len, COMMAND_OUTPUT_MAX)) { - fr_strerror_printf("Command count would overflow data buffer (shouldn't happen)"); + fr_strerror_const("Command count would overflow data buffer (shouldn't happen)"); RETURN_COMMAND_ERROR(); } @@ -1265,7 +1265,7 @@ static size_t command_decode_pair(command_result_t *result, command_file_ctx_t * slen = load_test_point_by_command((void **)&tp, in, "tp_decode_pair"); if (!tp) { - fr_strerror_printf_push("Failed locating decoder testpoint"); + fr_strerror_const_push("Failed locating decoder testpoint"); RETURN_COMMAND_ERROR(); } @@ -1273,7 +1273,7 @@ static size_t command_decode_pair(command_result_t *result, command_file_ctx_t * fr_skip_whitespace(p); if (tp->test_ctx && (tp->test_ctx(&decoder_ctx, cc->tmp_ctx) < 0)) { - fr_strerror_printf_push("Failed initialising decoder testpoint"); + fr_strerror_const_push("Failed initialising decoder testpoint"); RETURN_COMMAND_ERROR(); } @@ -1348,7 +1348,7 @@ static size_t command_decode_pair(command_result_t *result, command_file_ctx_t * vp = fr_cursor_next(&cursor)) { if ((slen = fr_pair_print(&FR_SBUFF_OUT(p, end), NULL, vp)) < 0) { oob: - fr_strerror_printf("Out of output buffer space"); + fr_strerror_const("Out of output buffer space"); CLEAR_TEST_POINT(cc); RETURN_COMMAND_ERROR(); } @@ -1388,7 +1388,7 @@ static size_t command_decode_proto(command_result_t *result, command_file_ctx_t slen = load_test_point_by_command((void **)&tp, in, "tp_decode_proto"); if (!tp) { - fr_strerror_printf_push("Failed locating decoder testpoint"); + fr_strerror_const_push("Failed locating decoder testpoint"); RETURN_COMMAND_ERROR(); } @@ -1396,7 +1396,7 @@ static size_t command_decode_proto(command_result_t *result, command_file_ctx_t fr_skip_whitespace(p); if (tp->test_ctx && (tp->test_ctx(&decoder_ctx, cc->tmp_ctx) < 0)) { - fr_strerror_printf_push("Failed initialising decoder testpoint"); + fr_strerror_const_push("Failed initialising decoder testpoint"); RETURN_COMMAND_ERROR(); } @@ -1605,7 +1605,7 @@ static size_t command_encode_pair(command_result_t *result, command_file_ctx_t * fr_pair_list_init(&head); slen = load_test_point_by_command((void **)&tp, p, "tp_encode_pair"); if (!tp) { - fr_strerror_printf_push("Failed locating encode testpoint"); + fr_strerror_const_push("Failed locating encode testpoint"); CLEAR_TEST_POINT(cc); RETURN_COMMAND_ERROR(); } @@ -1630,7 +1630,7 @@ static size_t command_encode_pair(command_result_t *result, command_file_ctx_t * } if (tp->test_ctx && (tp->test_ctx(&encoder_ctx, cc->tmp_ctx) < 0)) { - fr_strerror_printf_push("Failed initialising encoder testpoint"); + fr_strerror_const_push("Failed initialising encoder testpoint"); CLEAR_TEST_POINT(cc); RETURN_COMMAND_ERROR(); } @@ -1750,7 +1750,7 @@ static size_t command_encode_raw(command_result_t *result, command_file_ctx_t *c if (len <= 0) RETURN_PARSE_ERROR(0); if (len >= (size_t)(cc->buffer_end - cc->buffer_start)) { - fr_strerror_printf("Encoder output would overflow output buffer"); + fr_strerror_const("Encoder output would overflow output buffer"); RETURN_OK_WITH_ERROR(); } @@ -1777,7 +1777,7 @@ static size_t command_encode_proto(command_result_t *result, command_file_ctx_t slen = load_test_point_by_command((void **)&tp, p, "tp_encode_proto"); if (!tp) { - fr_strerror_printf_push("Failed locating encode testpoint"); + fr_strerror_const_push("Failed locating encode testpoint"); CLEAR_TEST_POINT(cc); RETURN_COMMAND_ERROR(); } @@ -1785,7 +1785,7 @@ static size_t command_encode_proto(command_result_t *result, command_file_ctx_t p += ((size_t)slen); fr_skip_whitespace(p); if (tp->test_ctx && (tp->test_ctx(&encoder_ctx, cc->tmp_ctx) < 0)) { - fr_strerror_printf_push("Failed initialising encoder testpoint"); + fr_strerror_const_push("Failed initialising encoder testpoint"); CLEAR_TEST_POINT(cc); RETURN_COMMAND_ERROR(); } @@ -1899,7 +1899,7 @@ static size_t command_max_buffer_size(command_result_t *result, command_file_ctx if (*in != '\0') { size = strtoul(in, &end, 10); if ((size == ULONG_MAX) || *end || (size >= 65536)) { - fr_strerror_printf_push("Invalid integer"); + fr_strerror_const_push("Invalid integer"); RETURN_COMMAND_ERROR(); } } else { @@ -2243,7 +2243,7 @@ static size_t command_value_box_normalise(command_result_t *result, UNUSED comma * They MUST be identical */ if (fr_value_box_cmp(box, box2) != 0) { - fr_strerror_printf("ERROR value box reparsing failed. Results not identical"); + fr_strerror_const("ERROR value box reparsing failed. Results not identical"); fr_strerror_printf_push("out: %pV", box2); fr_strerror_printf_push("in: %pV", box); talloc_free(box2); diff --git a/src/bin/unit_test_map.c b/src/bin/unit_test_map.c index e41f5784bd4..fdbc9de5ed4 100644 --- a/src/bin/unit_test_map.c +++ b/src/bin/unit_test_map.c @@ -246,7 +246,7 @@ int main(int argc, char *argv[]) * Load the custom dictionary */ if (fr_dict_read(dict, raddb_dir, FR_DICTIONARY_FILE) == -1) { - fr_strerror_printf_push("Failed to initialize the dictionaries"); + fr_strerror_const_push("Failed to initialize the dictionaries"); fr_perror("unit_test_map"); EXIT_WITH_FAILURE; } diff --git a/src/bin/unit_test_module.c b/src/bin/unit_test_module.c index d832993f16e..e39ac6559de 100644 --- a/src/bin/unit_test_module.c +++ b/src/bin/unit_test_module.c @@ -247,7 +247,7 @@ static request_t *request_from_file(TALLOC_CTX *ctx, FILE *fp, fr_event_list_t * * "0" is uniformly the "bad packet" type. */ if (!request->packet->code) { - fr_strerror_printf("No 'Packet-Type' was found in the request list. Cannot send unknown packet"); + fr_strerror_const("No 'Packet-Type' was found in the request list. Cannot send unknown packet"); return NULL; } diff --git a/src/lib/eap/base.c b/src/lib/eap/base.c index c611e729a5e..0cf9fb159af 100644 --- a/src/lib/eap/base.c +++ b/src/lib/eap/base.c @@ -206,21 +206,21 @@ static bool eap_is_valid(eap_packet_raw_t **eap_packet_p) uint8_t *p, *q; if (len <= (EAP_HEADER_LEN + 1 + 3 + 4)) { - fr_strerror_printf("Expanded EAP type is too short: ignoring the packet"); + fr_strerror_const("Expanded EAP type is too short: ignoring the packet"); return false; } if ((eap_packet->data[1] != 0) || (eap_packet->data[2] != 0) || (eap_packet->data[3] != 0)) { - fr_strerror_printf("Expanded EAP type has unknown Vendor-ID: ignoring the packet"); + fr_strerror_const("Expanded EAP type has unknown Vendor-ID: ignoring the packet"); return false; } if ((eap_packet->data[4] != 0) || (eap_packet->data[5] != 0) || (eap_packet->data[6] != 0)) { - fr_strerror_printf("Expanded EAP type has unknown Vendor-Type: ignoring the packet"); + fr_strerror_const("Expanded EAP type has unknown Vendor-Type: ignoring the packet"); return false; } @@ -232,7 +232,7 @@ static bool eap_is_valid(eap_packet_raw_t **eap_packet_p) } if (eap_packet->data[7] == FR_EAP_METHOD_NAK) { - fr_strerror_printf("Unsupported Expanded EAP-NAK: ignoring the packet"); + fr_strerror_const("Unsupported Expanded EAP-NAK: ignoring the packet"); return false; } @@ -265,7 +265,7 @@ static bool eap_is_valid(eap_packet_raw_t **eap_packet_p) /* we don't expect notification, but we send it */ if (eap_packet->data[0] == FR_EAP_METHOD_NOTIFICATION) { - fr_strerror_printf("Got NOTIFICATION, Ignoring the packet"); + fr_strerror_const("Got NOTIFICATION, Ignoring the packet"); return false; } @@ -293,7 +293,7 @@ eap_packet_raw_t *eap_packet_from_vp(TALLOC_CTX *ctx, fr_pair_list_t *vps) */ vp = fr_cursor_iter_by_da_init(&cursor, vps, attr_eap_message); if (!vp) { - fr_strerror_printf("EAP-Message not found"); + fr_strerror_const("EAP-Message not found"); return NULL; } @@ -301,7 +301,7 @@ eap_packet_raw_t *eap_packet_from_vp(TALLOC_CTX *ctx, fr_pair_list_t *vps) * Sanity check the length before doing anything. */ if (vp->vp_length < 4) { - fr_strerror_printf("EAP packet is too short"); + fr_strerror_const("EAP packet is too short"); return NULL; } @@ -316,7 +316,7 @@ eap_packet_raw_t *eap_packet_from_vp(TALLOC_CTX *ctx, fr_pair_list_t *vps) * Take out even more weird things. */ if (len < 4) { - fr_strerror_printf("EAP packet has invalid length (less than 4 bytes)"); + fr_strerror_const("EAP packet has invalid length (less than 4 bytes)"); return NULL; } diff --git a/src/lib/eap_aka_sim/crypto.c b/src/lib/eap_aka_sim/crypto.c index 8d75915220a..438ec229009 100644 --- a/src/lib/eap_aka_sim/crypto.c +++ b/src/lib/eap_aka_sim/crypto.c @@ -72,7 +72,7 @@ int fr_aka_sim_crypto_init_checkcode(TALLOC_CTX *ctx, fr_aka_sim_checkcode_t **c { *checkcode = talloc_zero(ctx, fr_aka_sim_checkcode_t); if (!*checkcode) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } @@ -198,7 +198,7 @@ static int fr_aka_sim_find_mac(uint8_t const **out, uint8_t *data, size_t data_l p += p[1] << 2; /* Advance */ } - fr_strerror_printf("No MAC attribute found"); + fr_strerror_const("No MAC attribute found"); return 1; } @@ -249,17 +249,17 @@ ssize_t fr_aka_sim_crypto_sign_packet(uint8_t out[static AKA_SIM_MAC_DIGEST_SIZE uint16_t packet_len; if (unlikely(!eap_packet)) { - fr_strerror_printf("Invalid argument: eap_packet is NULL"); + fr_strerror_const("Invalid argument: eap_packet is NULL"); return -1; } if (unlikely(!md)) { - fr_strerror_printf("Invalid argument: md is NULL"); + fr_strerror_const("Invalid argument: md is NULL"); return -1; } if (unlikely(!key) || (key_len == 0)) { - fr_strerror_printf("Invalid argument: key is NULL"); + fr_strerror_const("Invalid argument: key is NULL"); return -1; } @@ -949,7 +949,7 @@ int fr_aka_sim_crypto_kdf_0_reauth(fr_aka_sim_keys_t *keys) * the peer initialize the counter to one." */ if (keys->reauth.counter == 0) { - fr_strerror_printf("Re-authentication counter not initialised, must be >= 1"); + fr_strerror_const("Re-authentication counter not initialised, must be >= 1"); return -1; } diff --git a/src/lib/eap_aka_sim/decode.c b/src/lib/eap_aka_sim/decode.c index 0e30bb8dd21..d80ad921816 100644 --- a/src/lib/eap_aka_sim/decode.c +++ b/src/lib/eap_aka_sim/decode.c @@ -1017,7 +1017,7 @@ int fr_aka_sim_decode(request_t *request, fr_cursor_t *decoded, fr_dict_t const vp = fr_pair_afrom_child_num(request->packet, fr_dict_root(dict), FR_SUBTYPE); if (!vp) { - fr_strerror_printf("Failed allocating subtype attribute"); + fr_strerror_const("Failed allocating subtype attribute"); goto error; } vp->vp_uint32 = data[0]; diff --git a/src/lib/eap_aka_sim/id.c b/src/lib/eap_aka_sim/id.c index 454d496e78b..ed22d5c50fa 100644 --- a/src/lib/eap_aka_sim/id.c +++ b/src/lib/eap_aka_sim/id.c @@ -103,37 +103,37 @@ ssize_t fr_aka_sim_3gpp_root_nai_domain_mcc_mnc(uint16_t *mnc, uint16_t *mcc, p += 8; if (((p + 3) < end)) { - fr_strerror_printf("Missing MNC component"); + fr_strerror_const("Missing MNC component"); return (domain - p); } num = strtoul(p, &q, 10); if (*q != '.') { - fr_strerror_printf("Invalid MCN component"); + fr_strerror_const("Invalid MCN component"); return (domain - q); } *mnc = (uint16_t)num; p = q + 1; if (((p + 3) < end) || (CRYPTO_memcmp(p, "mcc", 3) != 0)) { - fr_strerror_printf("Missing MCC component"); + fr_strerror_const("Missing MCC component"); return (domain - p); } num = strtoul(p, &q, 10); if (*q != '.') { - fr_strerror_printf("Invalid MCC component"); + fr_strerror_const("Invalid MCC component"); return (domain - q); } *mcc = (uint16_t)num; p = q + 1; if (((p + 15) < end) || (CRYPTO_memcmp(p, "3gppnetwork.org", 15) != 0)) { - fr_strerror_printf("Missing 3gppnetwork.org suffix"); + fr_strerror_const("Missing 3gppnetwork.org suffix"); return (domain - p); } p += 15; if (p != end) { - fr_strerror_printf("Trailing garbage"); + fr_strerror_const("Trailing garbage"); return (domain - p); } @@ -169,7 +169,7 @@ int fr_aka_sim_id_type(fr_aka_sim_id_type_t *type, fr_aka_sim_method_hint_t *hin if (id_len < 1) { *hint = AKA_SIM_METHOD_HINT_UNKNOWN; *type = AKA_SIM_ID_TYPE_UNKNOWN; - fr_strerror_printf("ID length too short"); + fr_strerror_const("ID length too short"); return -1; } @@ -268,13 +268,13 @@ bad_format: case ID_TAG_SIM_PERMANENT: *hint = AKA_SIM_METHOD_HINT_UNKNOWN; *type = AKA_SIM_ID_TYPE_UNKNOWN; - fr_strerror_printf_push("Got SIM-Permanent-ID tag, but identity is not a permanent ID"); + fr_strerror_const_push("Got SIM-Permanent-ID tag, but identity is not a permanent ID"); return -1; case ID_TAG_AKA_PERMANENT: *hint = AKA_SIM_METHOD_HINT_UNKNOWN; *type = AKA_SIM_ID_TYPE_UNKNOWN; - fr_strerror_printf_push("Got AKA-Permanent-ID tag, but identity is not a permanent ID"); + fr_strerror_const_push("Got AKA-Permanent-ID tag, but identity is not a permanent ID"); return -1; default: @@ -374,7 +374,7 @@ int fr_aka_sim_id_3gpp_pseudonym_encrypt(char out[AKA_SIM_3GPP_PSEUDONYM_LEN + 1 return -1; } if (unlikely(!key)) { - fr_strerror_printf("Provided key was NULL"); + fr_strerror_const("Provided key was NULL"); return -1; } @@ -392,7 +392,7 @@ int fr_aka_sim_id_3gpp_pseudonym_encrypt(char out[AKA_SIM_3GPP_PSEUDONYM_LEN + 1 */ while (p < end) { if (unlikely(!isdigit((char)p[0]) || !isdigit((char)p[1]))) { - fr_strerror_printf("IMSI contains invalid character"); + fr_strerror_const("IMSI contains invalid character"); return -1; } diff --git a/src/lib/io/channel.c b/src/lib/io/channel.c index 75f1baa4f9b..a21added6d7 100644 --- a/src/lib/io/channel.c +++ b/src/lib/io/channel.c @@ -188,7 +188,7 @@ fr_channel_t *fr_channel_create(TALLOC_CTX *ctx, fr_control_t *requestor, fr_con ch = talloc_zero(ctx, fr_channel_t); if (!ch) { nomem: - fr_strerror_printf("Failed allocating memory"); + fr_strerror_const("Failed allocating memory"); return NULL; } @@ -219,7 +219,7 @@ fr_channel_t *fr_channel_create(TALLOC_CTX *ctx, fr_control_t *requestor, fr_con ch->end[TO_RESPONDER].rb = fr_ring_buffer_create(ch, FR_CONTROL_MAX_MESSAGES * FR_CONTROL_MAX_SIZE); if (!ch->end[TO_RESPONDER].rb) { rb_nomem: - fr_strerror_printf_push("Failed allocating ring buffer"); + fr_strerror_const_push("Failed allocating ring buffer"); talloc_free(ch); return NULL; } diff --git a/src/lib/io/control.c b/src/lib/io/control.c index 13bc5b4626d..cd680112c3f 100644 --- a/src/lib/io/control.c +++ b/src/lib/io/control.c @@ -152,7 +152,7 @@ fr_control_t *fr_control_create(TALLOC_CTX *ctx, fr_event_list_t *el, fr_atomic_ c = talloc_zero(ctx, fr_control_t); if (!c) { - fr_strerror_printf("Failed allocating memory"); + fr_strerror_const("Failed allocating memory"); return NULL; } c->el = el; @@ -173,7 +173,7 @@ fr_control_t *fr_control_create(TALLOC_CTX *ctx, fr_event_list_t *el, fr_atomic_ if (fr_event_fd_insert(c, el, c->pipe[0], pipe_read, NULL, NULL, c) < 0) { talloc_free(c); - fr_strerror_printf_push("Failed adding FD to event list control socket"); + fr_strerror_const_push("Failed adding FD to event list control socket"); return NULL; } @@ -229,7 +229,7 @@ int fr_control_gc(UNUSED fr_control_t *c, fr_ring_buffer_t *rb) * Maybe we failed to garbage collect everything? */ if (fr_ring_buffer_used(rb) > 0) { - fr_strerror_printf("Data still in control buffers"); + fr_strerror_const("Data still in control buffers"); return -1; } @@ -264,7 +264,7 @@ static fr_control_message_t *fr_control_message_alloc(fr_control_t *c, fr_ring_b (void) fr_control_gc(c, rb); m = (fr_control_message_t *) fr_ring_buffer_alloc(rb, message_size); if (!m) { - fr_strerror_printf_push("Failed allocating from ring buffer"); + fr_strerror_const_push("Failed allocating from ring buffer"); return NULL; } } @@ -313,14 +313,14 @@ int fr_control_message_push(fr_control_t *c, fr_ring_buffer_t *rb, uint32_t id, (void) fr_control_gc(c, rb); m = fr_control_message_alloc(c, rb, id, data, data_size); if (!m) { - fr_strerror_printf("Failed allocationg after GC"); + fr_strerror_const("Failed allocationg after GC"); return -2; } } if (!fr_atomic_queue_push(c->aq, m)) { m->status = FR_CONTROL_MESSAGE_DONE; - fr_strerror_printf("Failed pushing message to atomic queue."); + fr_strerror_const("Failed pushing message to atomic queue."); return -1; } @@ -431,7 +431,7 @@ int fr_control_callback_add(fr_control_t *c, uint32_t id, void *ctx, fr_control_ } if (c->type[id].callback != NULL) { - fr_strerror_printf("Callback is already set"); + fr_strerror_const("Callback is already set"); return -1; } diff --git a/src/lib/io/master.c b/src/lib/io/master.c index cdfdbdf01f3..b2fa851e357 100644 --- a/src/lib/io/master.c +++ b/src/lib/io/master.c @@ -2745,7 +2745,7 @@ fr_trie_t *fr_master_io_network(TALLOC_CTX *ctx, int af, fr_ipaddr_t *allow, fr_ &allow[i].addr, allow[i].prefix); if (network && (network->prefix <= allow[i].prefix)) { fr_strerror_printf("Cannot add overlapping entry 'allow = %pV'", fr_box_ipaddr(allow[i])); - fr_strerror_printf("Entry is completely enclosed inside of a previously defined network."); + fr_strerror_const("Entry is completely enclosed inside of a previously defined network."); talloc_free(trie); return NULL; } @@ -2889,7 +2889,7 @@ int fr_master_io_listen(TALLOC_CTX *ctx, fr_io_instance_t *inst, fr_schedule_t * } if (!inst->app_io->thread_inst_size) { - fr_strerror_printf("IO modules MUST set 'thread_inst_size' when using the master IO handler."); + fr_strerror_const("IO modules MUST set 'thread_inst_size' when using the master IO handler."); return -1; } diff --git a/src/lib/io/message.c b/src/lib/io/message.c index b505a5e65bc..5c915df3365 100644 --- a/src/lib/io/message.c +++ b/src/lib/io/message.c @@ -132,7 +132,7 @@ fr_message_set_t *fr_message_set_create(TALLOC_CTX *ctx, int num_messages, size_ if (num_messages < 8) num_messages = 8; if ((num_messages & (num_messages - 1)) != 0) { - fr_strerror_printf("Number of messages must be a power of 2"); + fr_strerror_const("Number of messages must be a power of 2"); return NULL; } @@ -142,13 +142,13 @@ fr_message_set_t *fr_message_set_create(TALLOC_CTX *ctx, int num_messages, size_ } if (message_size > 1024) { - fr_strerror_printf("Message size must be no larger than 1024"); + fr_strerror_const("Message size must be no larger than 1024"); return NULL; } ms = talloc_zero(ctx, fr_message_set_t); if (!ms) { - fr_strerror_printf("Failed allocating memory"); + fr_strerror_const("Failed allocating memory"); return NULL; } @@ -214,7 +214,7 @@ int fr_message_done(fr_message_t *m) */ fr_assert(0 == 1); - fr_strerror_printf("Failed marking message as done"); + fr_strerror_const("Failed marking message as done"); return -1; } @@ -243,19 +243,19 @@ fr_message_t *fr_message_localize(TALLOC_CTX *ctx, fr_message_t *m, size_t messa fr_message_t *l; if (m->status != FR_MESSAGE_USED) { - fr_strerror_printf("Cannot localize message unless it is in use"); + fr_strerror_const("Cannot localize message unless it is in use"); return NULL; } if (message_size <= sizeof(fr_message_t)) { - fr_strerror_printf("Message size is too small"); + fr_strerror_const("Message size is too small"); return NULL; } l = talloc_memdup(ctx, m, message_size); if (!l) { nomem: - fr_strerror_printf("Failed allocating memory"); + fr_strerror_const("Failed allocating memory"); return NULL; } @@ -640,7 +640,7 @@ static fr_message_t *fr_message_ring_alloc(fr_message_set_t *ms, fr_ring_buffer_ */ if (clean) { if (fr_message_ring_gc(ms, mr, 4) == 0) { - fr_strerror_printf("No free memory after GC attempt"); + fr_strerror_const("No free memory after GC attempt"); return NULL; } @@ -744,7 +744,7 @@ static fr_message_t *fr_message_get_message(fr_message_set_t *ms, bool *p_cleane * room to allocate another array, we're dead. */ if ((ms->mr_max + 1) >= MSG_ARRAY_SIZE) { - fr_strerror_printf("All message arrays are full"); + fr_strerror_const("All message arrays are full"); return NULL; } @@ -754,7 +754,7 @@ static fr_message_t *fr_message_get_message(fr_message_set_t *ms, bool *p_cleane */ mr = fr_ring_buffer_create(ms, fr_ring_buffer_size(ms->mr_array[ms->mr_max]) * 2); if (!mr) { - fr_strerror_printf_push("Failed allocating ring buffer"); + fr_strerror_const_push("Failed allocating ring buffer"); return NULL; } @@ -866,7 +866,7 @@ static fr_message_t *fr_message_get_ring_buffer(fr_message_set_t *ms, fr_message * room to allocate another array, we're dead. */ if ((ms->rb_max + 1) >= MSG_ARRAY_SIZE) { - fr_strerror_printf("Message arrays are full"); + fr_strerror_const("Message arrays are full"); goto cleanup; } @@ -877,7 +877,7 @@ alloc_rb: */ rb = fr_ring_buffer_create(ms, fr_ring_buffer_size(ms->rb_array[ms->rb_max]) * 2); if (!rb) { - fr_strerror_printf_push("Failed allocating ring buffer"); + fr_strerror_const_push("Failed allocating ring buffer"); goto cleanup; } @@ -1006,7 +1006,7 @@ fr_message_t *fr_message_alloc(fr_message_set_t *ms, fr_message_t *m, size_t act p = fr_ring_buffer_alloc(m->rb, actual_packet_size); fr_assert(p != NULL); if (!p) { - fr_strerror_printf_push("Failed allocating from ring buffer"); + fr_strerror_const_push("Failed allocating from ring buffer"); return NULL; } @@ -1083,7 +1083,7 @@ fr_message_t *fr_message_alloc_reserve(fr_message_set_t *ms, fr_message_t *m, si p = fr_ring_buffer_alloc(m->rb, actual_packet_size); fr_assert(p != NULL); if (!p) { - fr_strerror_printf_push("Failed allocating from ring buffer"); + fr_strerror_const_push("Failed allocating from ring buffer"); return NULL; } @@ -1219,7 +1219,7 @@ fr_message_t *fr_message_alloc_aligned(fr_message_set_t *ms, fr_message_t *m, si aligned_size = MS_ALIGN(actual_packet_size); if ((aligned_p + aligned_size) > (m->data + m->rb_size)) { - fr_strerror_printf("Aligned message size overflows reserved size"); + fr_strerror_const("Aligned message size overflows reserved size"); return NULL; } @@ -1234,7 +1234,7 @@ fr_message_t *fr_message_alloc_aligned(fr_message_set_t *ms, fr_message_t *m, si p = fr_ring_buffer_alloc(m->rb, aligned_size); fr_assert(p != NULL); if (!p) { - fr_strerror_printf_push("Failed allocating from ring buffer"); + fr_strerror_const_push("Failed allocating from ring buffer"); return NULL; } diff --git a/src/lib/io/network.c b/src/lib/io/network.c index aaa0f5e6190..4a415a344a6 100644 --- a/src/lib/io/network.c +++ b/src/lib/io/network.c @@ -1583,7 +1583,7 @@ fr_network_t *fr_network_create(TALLOC_CTX *ctx, fr_event_list_t *el, char const nr = talloc_zero(ctx, fr_network_t); if (!nr) { - fr_strerror_printf("Failed allocating memory"); + fr_strerror_const("Failed allocating memory"); return NULL; } talloc_set_destructor(nr, _fr_network_free); @@ -1606,7 +1606,7 @@ fr_network_t *fr_network_create(TALLOC_CTX *ctx, fr_event_list_t *el, char const nr->control = fr_control_create(nr, el, nr->aq_control); if (!nr->control) { - fr_strerror_printf_push("Failed creating control queue"); + fr_strerror_const_push("Failed creating control queue"); fail: talloc_free(nr); return NULL; @@ -1620,34 +1620,34 @@ fr_network_t *fr_network_create(TALLOC_CTX *ctx, fr_event_list_t *el, char const */ nr->rb = fr_ring_buffer_create(nr, FR_CONTROL_MAX_MESSAGES * FR_CONTROL_MAX_SIZE); if (!nr->rb) { - fr_strerror_printf_push("Failed creating ring buffer"); + fr_strerror_const_push("Failed creating ring buffer"); fail2: talloc_free(nr->control); goto fail; } if (fr_control_callback_add(nr->control, FR_CONTROL_ID_CHANNEL, nr, fr_network_channel_callback) < 0) { - fr_strerror_printf_push("Failed adding channel callback"); + fr_strerror_const_push("Failed adding channel callback"); goto fail2; } if (fr_control_callback_add(nr->control, FR_CONTROL_ID_LISTEN, nr, fr_network_listen_callback) < 0) { - fr_strerror_printf_push("Failed adding socket callback"); + fr_strerror_const_push("Failed adding socket callback"); goto fail2; } if (fr_control_callback_add(nr->control, FR_CONTROL_ID_DIRECTORY, nr, fr_network_directory_callback) < 0) { - fr_strerror_printf_push("Failed adding socket callback"); + fr_strerror_const_push("Failed adding socket callback"); goto fail2; } if (fr_control_callback_add(nr->control, FR_CONTROL_ID_WORKER, nr, fr_network_worker_started_callback) < 0) { - fr_strerror_printf_push("Failed adding worker callback"); + fr_strerror_const_push("Failed adding worker callback"); goto fail2; } if (fr_control_callback_add(nr->control, FR_CONTROL_ID_INJECT, nr, fr_network_inject_callback) < 0) { - fr_strerror_printf_push("Failed adding packet injection callback"); + fr_strerror_const_push("Failed adding packet injection callback"); goto fail2; } @@ -1656,29 +1656,29 @@ fr_network_t *fr_network_create(TALLOC_CTX *ctx, fr_event_list_t *el, char const */ nr->sockets = rbtree_talloc_alloc(nr, socket_listen_cmp, fr_network_socket_t, NULL, RBTREE_FLAG_NONE); if (!nr->sockets) { - fr_strerror_printf_push("Failed creating listen tree for sockets"); + fr_strerror_const_push("Failed creating listen tree for sockets"); goto fail2; } nr->sockets_by_num = rbtree_talloc_alloc(nr, socket_num_cmp, fr_network_socket_t, NULL, RBTREE_FLAG_NONE); if (!nr->sockets_by_num) { - fr_strerror_printf_push("Failed creating number tree for sockets"); + fr_strerror_const_push("Failed creating number tree for sockets"); goto fail2; } nr->replies = fr_heap_alloc(nr, reply_cmp, fr_channel_data_t, channel.heap_id); if (!nr->replies) { - fr_strerror_printf_push("Failed creating heap for replies"); + fr_strerror_const_push("Failed creating heap for replies"); goto fail2; } if (fr_event_pre_insert(nr->el, fr_network_pre_event, nr) < 0) { - fr_strerror_printf("Failed adding pre-check to event list"); + fr_strerror_const("Failed adding pre-check to event list"); goto fail2; } if (fr_event_post_insert(nr->el, fr_network_post_event, nr) < 0) { - fr_strerror_printf("Failed inserting post-processing event"); + fr_strerror_const("Failed inserting post-processing event"); goto fail2; } @@ -1690,7 +1690,7 @@ fr_network_t *fr_network_create(TALLOC_CTX *ctx, fr_event_list_t *el, char const if (fr_nonblock(nr->signal_pipe[1]) < 0) goto fail2; if (fr_event_fd_insert(nr, nr->el, nr->signal_pipe[0], _signal_pipe_read, NULL, NULL, nr) < 0) { - fr_strerror_printf("Failed inserting event for signal pipe"); + fr_strerror_const("Failed inserting event for signal pipe"); goto fail2; } diff --git a/src/lib/io/ring_buffer.c b/src/lib/io/ring_buffer.c index fc6cfea75a9..b8600e87b93 100644 --- a/src/lib/io/ring_buffer.c +++ b/src/lib/io/ring_buffer.c @@ -68,14 +68,14 @@ fr_ring_buffer_t *fr_ring_buffer_create(TALLOC_CTX *ctx, size_t size) rb = talloc_zero(ctx, fr_ring_buffer_t); if (!rb) { fail: - fr_strerror_printf("Failed allocating memory."); + fr_strerror_const("Failed allocating memory."); return NULL; } if (size < 1024) size = 1024; if (size > (1 << 30)) { - fr_strerror_printf("Ring buffer size must be no more than (1 << 30)"); + fr_strerror_const("Ring buffer size must be no more than (1 << 30)"); talloc_free(rb); return NULL; } @@ -121,7 +121,7 @@ uint8_t *fr_ring_buffer_reserve(fr_ring_buffer_t *rb, size_t size) (void) talloc_get_type_abort(rb, fr_ring_buffer_t); if (rb->closed) { - fr_strerror_printf("Allocation request after ring buffer is closed"); + fr_strerror_const("Allocation request after ring buffer is closed"); return NULL; } @@ -137,7 +137,7 @@ uint8_t *fr_ring_buffer_reserve(fr_ring_buffer_t *rb, size_t size) return rb->buffer + rb->write_offset; } - fr_strerror_printf("No memory available in ring buffer"); + fr_strerror_const("No memory available in ring buffer"); return NULL; } @@ -171,7 +171,7 @@ uint8_t *fr_ring_buffer_reserve(fr_ring_buffer_t *rb, size_t size) * * |....S****WE....| */ - fr_strerror_printf("No memory available in ring buffer"); + fr_strerror_const("No memory available in ring buffer"); return NULL; } @@ -201,7 +201,7 @@ uint8_t *fr_ring_buffer_alloc(fr_ring_buffer_t *rb, size_t size) if (rb->closed) { #ifndef NDEBUG - fr_strerror_printf("Allocation request after ring buffer is closed"); + fr_strerror_const("Allocation request after ring buffer is closed"); #endif return NULL; } @@ -230,7 +230,7 @@ uint8_t *fr_ring_buffer_alloc(fr_ring_buffer_t *rb, size_t size) } #ifndef NDEBUG - fr_strerror_printf("No memory available in ring buffer"); + fr_strerror_const("No memory available in ring buffer"); #endif return NULL; } @@ -280,7 +280,7 @@ uint8_t *fr_ring_buffer_alloc(fr_ring_buffer_t *rb, size_t size) * |....S****WE....| */ #ifndef NDEBUG - fr_strerror_printf("No memory available in ring buffer"); + fr_strerror_const("No memory available in ring buffer"); #endif return NULL; } @@ -332,7 +332,7 @@ uint8_t *fr_ring_buffer_reserve_split(fr_ring_buffer_t *dst, size_t reserve_size (void) talloc_get_type_abort(dst, fr_ring_buffer_t); if (dst->closed) { - fr_strerror_printf("Allocation request after ring buffer is closed"); + fr_strerror_const("Allocation request after ring buffer is closed"); return NULL; } @@ -341,7 +341,7 @@ uint8_t *fr_ring_buffer_reserve_split(fr_ring_buffer_t *dst, size_t reserve_size * split the reservation. */ if (src->reserved < move_size) { - fr_strerror_printf("Cannot move more data than was reserved."); + fr_strerror_const("Cannot move more data than was reserved."); return NULL; } @@ -450,7 +450,7 @@ int fr_ring_buffer_free(fr_ring_buffer_t *rb, size_t size_to_free) * Freeing too much, return an error. */ if (size_to_free > block_size) { - fr_strerror_printf("Cannot free more memory than exists."); + fr_strerror_const("Cannot free more memory than exists."); return -1; } diff --git a/src/lib/io/schedule.c b/src/lib/io/schedule.c index f92337b508a..0335e2316bd 100644 --- a/src/lib/io/schedule.c +++ b/src/lib/io/schedule.c @@ -416,7 +416,7 @@ fr_schedule_t *fr_schedule_create(TALLOC_CTX *ctx, fr_event_list_t *el, sc = talloc_zero(ctx, fr_schedule_t); if (!sc) { - fr_strerror_printf("Failed allocating memory"); + fr_strerror_const("Failed allocating memory"); return NULL; } @@ -487,7 +487,7 @@ fr_schedule_t *fr_schedule_create(TALLOC_CTX *ctx, fr_event_list_t *el, DEBUG("Scheduler created in single-threaded mode"); if (fr_event_pre_insert(el, fr_worker_pre_event, sc->single_worker) < 0) { - fr_strerror_printf("Failed adding pre-check to event list"); + fr_strerror_const("Failed adding pre-check to event list"); goto st_fail; } @@ -495,7 +495,7 @@ fr_schedule_t *fr_schedule_create(TALLOC_CTX *ctx, fr_event_list_t *el, * Add the event which processes request_t packets. */ if (fr_event_post_insert(el, fr_worker_post_event, sc->single_worker) < 0) { - fr_strerror_printf("Failed inserting post-processing event"); + fr_strerror_const("Failed inserting post-processing event"); goto st_fail; } diff --git a/src/lib/io/worker.c b/src/lib/io/worker.c index 8110a2a6437..937b89efa2b 100644 --- a/src/lib/io/worker.c +++ b/src/lib/io/worker.c @@ -1079,7 +1079,7 @@ fr_worker_t *fr_worker_create(TALLOC_CTX *ctx, fr_event_list_t *el, char const * worker = talloc_zero(ctx, fr_worker_t); if (!worker) { nomem: - fr_strerror_printf("Failed allocating memory"); + fr_strerror_const("Failed allocating memory"); return NULL; } @@ -1120,7 +1120,7 @@ nomem: worker->aq_control = fr_atomic_queue_alloc(worker, 1024); if (!worker->aq_control) { - fr_strerror_printf("Failed creating atomic queue"); + fr_strerror_const("Failed creating atomic queue"); fail: talloc_free(worker); return NULL; @@ -1128,30 +1128,30 @@ nomem: worker->control = fr_control_create(worker, el, worker->aq_control); if (!worker->control) { - fr_strerror_printf_push("Failed creating control plane"); + fr_strerror_const_push("Failed creating control plane"); goto fail; } if (fr_control_callback_add(worker->control, FR_CONTROL_ID_CHANNEL, worker, worker_channel_callback) < 0) { - fr_strerror_printf_push("Failed adding control channel"); + fr_strerror_const_push("Failed adding control channel"); goto fail; } worker->runnable = fr_heap_talloc_alloc(worker, worker_runnable_cmp, request_t, runnable_id); if (!worker->runnable) { - fr_strerror_printf("Failed creating runnable heap"); + fr_strerror_const("Failed creating runnable heap"); goto fail; } worker->time_order = fr_heap_talloc_alloc(worker, worker_time_order_cmp, request_t, time_order_id); if (!worker->time_order) { - fr_strerror_printf("Failed creating time_order heap"); + fr_strerror_const("Failed creating time_order heap"); goto fail; } worker->dedup = rbtree_talloc_alloc(worker, worker_dedup_cmp, request_t, NULL, RBTREE_FLAG_NONE); if (!worker->dedup) { - fr_strerror_printf("Failed creating de_dup tree"); + fr_strerror_const("Failed creating de_dup tree"); goto fail; } @@ -1255,13 +1255,13 @@ int fr_worker_request_add(request_t *request, module_method_t process, void *ctx fr_time_t now; if (!request || !process) { - fr_strerror_printf("Invalid arguments"); + fr_strerror_const("Invalid arguments"); return -1; } worker = thread_local_worker; if (!worker) { - fr_strerror_printf("No worker has been defined"); + fr_strerror_const("No worker has been defined"); return -1; } diff --git a/src/lib/json/jpath.c b/src/lib/json/jpath.c index 5bf73df3247..5e72a91c290 100644 --- a/src/lib/json/jpath.c +++ b/src/lib/json/jpath.c @@ -512,7 +512,7 @@ static ssize_t jpath_filter_expr_parse(UNUSED jpath_selector_t *selector, UNUSED { /* selector->type = JPATH_SELECTOR_FILTER_EXPRESSION; */ - fr_strerror_printf("Filter expressions not yet implemented"); + fr_strerror_const("Filter expressions not yet implemented"); return 0; } @@ -525,7 +525,7 @@ static ssize_t jpath_expr_parse(UNUSED jpath_selector_t *selector, UNUSED char c { /* selector->type = JPATH_SELECTOR_EXPRESSION; */ - fr_strerror_printf("Expressions not yet implemented"); + fr_strerror_const("Expressions not yet implemented"); return 0; } @@ -566,18 +566,18 @@ static ssize_t jpath_array_parse(jpath_selector_t *selector, char const *in, siz */ for (p = in; p < end; p++) if ((p[0] == ',') || (p[0] == ']')) break; if (p == end) { - fr_strerror_printf("Missing selector delimiter ',' or terminator ']'"); + fr_strerror_const("Missing selector delimiter ',' or terminator ']'"); return -inlen; } ret = (p - in); if (ret == 0) { - fr_strerror_printf("Empty selector"); + fr_strerror_const("Empty selector"); return 0; } if (inlen > sizeof(buffer)) { /* - 1 for ] */ - fr_strerror_printf("Selector too long"); + fr_strerror_const("Selector too long"); return -inlen; } @@ -596,7 +596,7 @@ static ssize_t jpath_array_parse(jpath_selector_t *selector, char const *in, siz if (q > p) switch (q[0]) { default: no_term: - fr_strerror_printf("Expected num, ':' or ']'"); + fr_strerror_const("Expected num, ':' or ']'"); return buffer - q; case ':': /* More integers to parse */ @@ -638,12 +638,12 @@ static ssize_t jpath_array_parse(jpath_selector_t *selector, char const *in, siz */ num = (int32_t)strtol(p, &q, 10); if (q[0] != '\0') { - fr_strerror_printf("Expected num or ']'"); + fr_strerror_const("Expected num or ']'"); return buffer - q; } if (q > p) { if (num == 0) { - fr_strerror_printf("Step cannot be 0"); + fr_strerror_const("Step cannot be 0"); return buffer - p; } selector->slice[idx] = num; @@ -669,13 +669,13 @@ static size_t jpath_field_parse(fr_jpath_node_t *node, char const *in, size_t in if (buff_p == buff_end) { name_too_big: - fr_strerror_printf("Exceeded maximum field name length"); + fr_strerror_const("Exceeded maximum field name length"); return in - p; } clen = fr_utf8_char((uint8_t const *)p, end - p); if (clen == 0) { - fr_strerror_printf("Bad UTF8 char"); + fr_strerror_const("Bad UTF8 char"); return in - p; } @@ -720,7 +720,7 @@ static size_t jpath_field_parse(fr_jpath_node_t *node, char const *in, size_t in } if (buff_p == buffer) { - fr_strerror_printf("Empty field specifier"); + fr_strerror_const("Empty field specifier"); return 0; } node->selector->field = talloc_bstrndup(node, buffer, buff_p - buffer); @@ -745,7 +745,7 @@ static size_t jpath_selector_parse(fr_jpath_node_t *node, char const *in, size_t if (++p == end) { /* Skip past [ */ missing_terminator: - fr_strerror_printf("Missing selector terminator ']'"); + fr_strerror_const("Missing selector terminator ']'"); return in - p; } @@ -793,7 +793,7 @@ static size_t jpath_selector_parse(fr_jpath_node_t *node, char const *in, size_t */ *stail = selector = talloc_zero(node, jpath_selector_t); if (!selector) { - fr_strerror_printf("Failed allocating selector"); + fr_strerror_const("Failed allocating selector"); return in - p; } stail = &selector->next; @@ -835,7 +835,7 @@ do { \ if (inlen < 1) { bad_start: - fr_strerror_printf("Expected root specifier '$', or current node specifier '@'"); + fr_strerror_const("Expected root specifier '$', or current node specifier '@'"); return 0; } @@ -901,7 +901,7 @@ do { \ node->selector->type = JPATH_SELECTOR_RECURSIVE_DESCENT; if ((p + 1) == end) { - fr_strerror_printf("Path may not end in recursive descent"); + fr_strerror_const("Path may not end in recursive descent"); goto error; } @@ -947,7 +947,7 @@ do { \ break; default: - fr_strerror_printf("Expected field specifier '.' or selector '['"); + fr_strerror_const("Expected field specifier '.' or selector '['"); goto error; } } diff --git a/src/lib/json/json.c b/src/lib/json/json.c index f83ce5b2397..3e94ac2b05b 100644 --- a/src/lib/json/json.c +++ b/src/lib/json/json.c @@ -537,7 +537,7 @@ static json_object *json_object_afrom_pair_list(TALLOC_CTX *ctx, fr_pair_list_t attr_name = attr_name_with_prefix(buf, sizeof(buf), vp->da->name, format); if (json_afrom_value_box(ctx, &value, vp, format) < 0) { - fr_strerror_printf("Failed to convert attribute value to JSON object"); + fr_strerror_const("Failed to convert attribute value to JSON object"); error: json_object_put(obj); return NULL; @@ -581,7 +581,7 @@ static json_object *json_object_afrom_pair_list(TALLOC_CTX *ctx, fr_pair_list_t * Find the 'values' array to add the current value to. */ if (!fr_cond_assert(json_object_object_get_ex(vp_object, "value", &values))) { - fr_strerror_printf("Inconsistent JSON tree"); + fr_strerror_const("Inconsistent JSON tree"); goto error; } @@ -659,7 +659,7 @@ static json_object *json_smplobj_afrom_pair_list(TALLOC_CTX *ctx, fr_pair_list_t attr_name = attr_name_with_prefix(buf, sizeof(buf), vp->da->name, format); if (json_afrom_value_box(ctx, &value, vp, format) < 0) { - fr_strerror_printf("Failed to convert attribute value to JSON object"); + fr_strerror_const("Failed to convert attribute value to JSON object"); json_object_put(obj); return NULL; } @@ -772,7 +772,7 @@ static struct json_object *json_array_afrom_pair_list(TALLOC_CTX *ctx, fr_pair_l attr_name = attr_name_with_prefix(buf, sizeof(buf), vp->da->name, format); if (json_afrom_value_box(ctx, &value, vp, format) < 0) { - fr_strerror_printf("Failed to convert attribute value to JSON object"); + fr_strerror_const("Failed to convert attribute value to JSON object"); json_object_put(obj); return NULL; } @@ -888,7 +888,7 @@ static struct json_object *json_value_array_afrom_pair_list(TALLOC_CTX *ctx, fr_ struct json_object *value; if (json_afrom_value_box(ctx, &value, vp, format) < 0) { - fr_strerror_printf("Failed to convert attribute value to JSON object"); + fr_strerror_const("Failed to convert attribute value to JSON object"); json_object_put(obj); return NULL; } diff --git a/src/lib/ldap/base.c b/src/lib/ldap/base.c index ed118272cb7..ebf24020e07 100644 --- a/src/lib/ldap/base.c +++ b/src/lib/ldap/base.c @@ -205,7 +205,7 @@ fr_ldap_rcode_t fr_ldap_error_check(LDAPControl ***ctrls, fr_ldap_connection_t c ldap_get_option(conn->handle, LDAP_OPT_ERROR_NUMBER, &lib_errno); if (lib_errno != LDAP_SUCCESS) goto process_error; - fr_strerror_printf("No result available"); + fr_strerror_const("No result available"); return LDAP_PROC_NO_RESULT; } @@ -261,16 +261,16 @@ process_error: switch (lib_errno) { case LDAP_SUCCESS: - fr_strerror_printf("Success"); + fr_strerror_const("Success"); break; case LDAP_SASL_BIND_IN_PROGRESS: - fr_strerror_printf("Continuing"); + fr_strerror_const("Continuing"); status = LDAP_PROC_CONTINUE; break; case LDAP_NO_SUCH_OBJECT: - fr_strerror_printf("The specified DN wasn't found"); + fr_strerror_const("The specified DN wasn't found"); status = LDAP_PROC_BAD_DN; /* @@ -293,27 +293,27 @@ process_error: goto error_string; case LDAP_INSUFFICIENT_ACCESS: - fr_strerror_printf("Insufficient access. Check the identity and password configuration directives"); + fr_strerror_const("Insufficient access. Check the identity and password configuration directives"); status = LDAP_PROC_NOT_PERMITTED; break; case LDAP_UNWILLING_TO_PERFORM: - fr_strerror_printf("Server was unwilling to perform"); + fr_strerror_const("Server was unwilling to perform"); status = LDAP_PROC_NOT_PERMITTED; break; case LDAP_FILTER_ERROR: - fr_strerror_printf("Bad search filter"); + fr_strerror_const("Bad search filter"); status = LDAP_PROC_ERROR; break; case LDAP_TIMEOUT: - fr_strerror_printf("Timed out while waiting for server to respond"); + fr_strerror_const("Timed out while waiting for server to respond"); status = LDAP_PROC_TIMEOUT; break; case LDAP_TIMELIMIT_EXCEEDED: - fr_strerror_printf("Time limit exceeded"); + fr_strerror_const("Time limit exceeded"); status = LDAP_PROC_TIMEOUT; break; @@ -422,7 +422,7 @@ fr_ldap_rcode_t fr_ldap_result(LDAPMessage **result, LDAPControl ***ctrls, switch (lib_errno) { case 0: lib_errno = LDAP_TIMEOUT; - fr_strerror_printf("timeout waiting for result"); + fr_strerror_const("timeout waiting for result"); return LDAP_PROC_TIMEOUT; case -1: diff --git a/src/lib/redis/cluster.c b/src/lib/redis/cluster.c index 1d81e587065..6ae80ddcd2b 100644 --- a/src/lib/redis/cluster.c +++ b/src/lib/redis/cluster.c @@ -448,11 +448,11 @@ static fr_redis_cluster_rcode_t cluster_node_conf_from_redirect(uint16_t *key_sl } else if (strncmp(REDIS_ERROR_ASK_STR, redirect->str, sizeof(REDIS_ERROR_ASK_STR) - 1) == 0) { q = p + sizeof(REDIS_ERROR_ASK_STR); /* not a typo, skip space too */ } else { - fr_strerror_printf("No '-MOVED' or '-ASK' log_prefix"); + fr_strerror_const("No '-MOVED' or '-ASK' log_prefix"); return FR_REDIS_CLUSTER_RCODE_BAD_INPUT; } if ((size_t)(q - p) >= (size_t)redirect->len) { - fr_strerror_printf("Truncated"); + fr_strerror_const("Truncated"); return FR_REDIS_CLUSTER_RCODE_BAD_INPUT; } p = q; @@ -464,7 +464,7 @@ static fr_redis_cluster_rcode_t cluster_node_conf_from_redirect(uint16_t *key_sl p = q; if (*p != ' ') { - fr_strerror_printf("Missing key/host separator"); + fr_strerror_const("Missing key/host separator"); return FR_REDIS_CLUSTER_RCODE_BAD_INPUT; } p++; /* Skip the ' ' */ @@ -615,7 +615,7 @@ do { \ spare = fr_fifo_peek(cluster->free_nodes); if (!spare) { out_of_nodes: - fr_strerror_printf("Reached maximum connected nodes"); + fr_strerror_const("Reached maximum connected nodes"); rcode = FR_REDIS_CLUSTER_RCODE_FAILED; error: cluster->remapping = false; @@ -858,7 +858,7 @@ static fr_redis_cluster_rcode_t cluster_map_get(redisReply **out, fr_redis_conn_ switch (fr_redis_command_status(conn, reply)) { case REDIS_RCODE_RECONNECT: fr_redis_reply_free(&reply); - fr_strerror_printf("No connections available"); + fr_strerror_const("No connections available"); return FR_REDIS_CLUSTER_RCODE_NO_CONNECTION; case REDIS_RCODE_ERROR: @@ -868,7 +868,7 @@ static fr_redis_cluster_rcode_t cluster_map_get(redisReply **out, fr_redis_conn_ fr_redis_reply_free(&reply); return FR_REDIS_CLUSTER_RCODE_IGNORED; } - fr_strerror_printf("Unknown client error"); + fr_strerror_const("Unknown client error"); return FR_REDIS_CLUSTER_RCODE_FAILED; case REDIS_RCODE_SUCCESS: @@ -1131,7 +1131,7 @@ static fr_redis_cluster_rcode_t cluster_redirect(fr_redis_cluster_node_t **out, */ spare = fr_fifo_peek(cluster->free_nodes); if (!spare) { - fr_strerror_printf("Reached maximum connected nodes"); + fr_strerror_const("Reached maximum connected nodes"); pthread_mutex_unlock(&cluster->mutex); return FR_REDIS_CLUSTER_RCODE_FAILED; } @@ -1164,7 +1164,7 @@ static fr_redis_cluster_rcode_t cluster_redirect(fr_redis_cluster_node_t **out, fr_fifo_push(cluster->free_nodes, spare); pthread_mutex_unlock(&cluster->mutex); - fr_strerror_printf("No connections available"); + fr_strerror_const("No connections available"); return FR_REDIS_CLUSTER_RCODE_NO_CONNECTION; } fr_pool_connection_release(found->pool, NULL, rconn); @@ -2053,7 +2053,7 @@ int fr_redis_cluster_pool_by_node_addr(fr_pool_t **pool, fr_redis_cluster_t *clu spare = fr_fifo_peek(cluster->free_nodes); if (!spare) { - fr_strerror_printf("Reached maximum connected nodes"); + fr_strerror_const("Reached maximum connected nodes"); pthread_mutex_unlock(&cluster->mutex); return -1; } @@ -2135,7 +2135,7 @@ ssize_t fr_redis_cluster_node_addr_by_role(TALLOC_CTX *ctx, fr_socket_t *out[], context.count = 0; context.found = talloc_zero_array(ctx, fr_socket_t, in_use); if (!context.found) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } diff --git a/src/lib/redis/redis.c b/src/lib/redis/redis.c index 4d39565e8de..bac252077a6 100644 --- a/src/lib/redis/redis.c +++ b/src/lib/redis/redis.c @@ -447,7 +447,7 @@ fr_redis_rcode_t fr_redis_pipeline_result(unsigned int *pipelined, fr_redis_rcod *pipelined = 0; /* all outstanding responses should be cleared */ - fr_strerror_printf("Too many pipelined commands"); + fr_strerror_const("Too many pipelined commands"); out[0] = NULL; return REDIS_RCODE_ERROR; } @@ -552,7 +552,7 @@ fr_redis_rcode_t fr_redis_get_version(char *out, size_t out_len, fr_redis_conn_t p = strstr(reply->str, "redis_version:"); if (!p) { - fr_strerror_printf("Response did not contain version string"); + fr_strerror_const("Response did not contain version string"); goto error; } diff --git a/src/lib/server/command.c b/src/lib/server/command.c index bfabaa49555..d51a2158f3b 100644 --- a/src/lib/server/command.c +++ b/src/lib/server/command.c @@ -177,7 +177,7 @@ static bool fr_command_valid_name(char const *name) for (p = (uint8_t const *) name; *p != '\0'; p++) { if (*p < ' ') { - fr_strerror_printf("Invalid control character in name"); + fr_strerror_const("Invalid control character in name"); return false; } @@ -186,7 +186,7 @@ static bool fr_command_valid_name(char const *name) ((*p >= '[') && (*p <= '^')) || ((*p > 'z') && (*p <= 0xf7)) || (*p == '`')) { - fr_strerror_printf("Invalid special character"); + fr_strerror_const("Invalid special character"); return false; } @@ -195,7 +195,7 @@ static bool fr_command_valid_name(char const *name) */ if (fr_utf8_char(p, -1)) continue; - fr_strerror_printf("Invalid non-UTF8 character in name"); + fr_strerror_const("Invalid non-UTF8 character in name"); } return true; @@ -311,7 +311,7 @@ static int split_alternation(char **input, char **output) */ while ((*str != end) || (count > 0)) { if (!*str) { - fr_strerror_printf("String ends before closing brace."); + fr_strerror_const("String ends before closing brace."); return -1; } @@ -333,7 +333,7 @@ static int split_alternation(char **input, char **output) (*str != ' ') && (*str != '|') && (*str != '\t')) { - fr_strerror_printf("Invalid text after quoted string."); + fr_strerror_const("Invalid text after quoted string."); return -1; } } else { @@ -427,7 +427,7 @@ static int split(char **input, char **output, bool syntax_string) while (*str != quote) { if (!*str) { - fr_strerror_printf("String is not terminated with a quotation character."); + fr_strerror_const("String is not terminated with a quotation character."); return -1; } @@ -437,7 +437,7 @@ static int split(char **input, char **output, bool syntax_string) if (*str == '\\') { str++; if (!*str) { - fr_strerror_printf("Invalid backslash at end of string."); + fr_strerror_const("Invalid backslash at end of string."); return -1; } str++; @@ -461,7 +461,7 @@ static int split(char **input, char **output, bool syntax_string) (*str != '\t') && (*str != '\r') && (*str != '\n')) { - fr_strerror_printf("Invalid text after quoted string."); + fr_strerror_const("Invalid text after quoted string."); return -1; } @@ -483,7 +483,7 @@ static int split(char **input, char **output, bool syntax_string) */ while ((*str != end) || (count > 0)) { if (!*str) { - fr_strerror_printf("String ends before closing brace."); + fr_strerror_const("String ends before closing brace."); return -1; } @@ -507,7 +507,7 @@ static int split(char **input, char **output, bool syntax_string) (*str != '\t') && (*str != '\r') && (*str != '\n')) { - fr_strerror_printf("Invalid text after quoted string."); + fr_strerror_const("Invalid text after quoted string."); return -1; } } else { @@ -573,12 +573,12 @@ static int fr_command_add_syntax(TALLOC_CTX *ctx, char *syntax, fr_cmd_argv_t ** */ if (strcmp(name, "...") == 0) { if (!allow_varargs) { - fr_strerror_printf("Varargs MUST NOT be in an [...] or (...) syntax."); + fr_strerror_const("Varargs MUST NOT be in an [...] or (...) syntax."); return -1; } if (!prev || *p) { - fr_strerror_printf("Varargs MUST be the last argument in the syntax list."); + fr_strerror_const("Varargs MUST be the last argument in the syntax list."); return -1; } @@ -587,7 +587,7 @@ static int fr_command_add_syntax(TALLOC_CTX *ctx, char *syntax, fr_cmd_argv_t ** * MUST be a known data type. */ if (prev->type >= FR_TYPE_FIXED) { - fr_strerror_printf("Varargs MUST be preceded by a data type."); + fr_strerror_const("Varargs MUST be preceded by a data type."); return -1; } argv = talloc_zero(ctx, fr_cmd_argv_t); @@ -605,7 +605,7 @@ static int fr_command_add_syntax(TALLOC_CTX *ctx, char *syntax, fr_cmd_argv_t ** q = option + strlen(option) - 1; if (*q != ']') { - fr_strerror_printf("Optional syntax is not properly terminated"); + fr_strerror_const("Optional syntax is not properly terminated"); return -1; } @@ -633,7 +633,7 @@ static int fr_command_add_syntax(TALLOC_CTX *ctx, char *syntax, fr_cmd_argv_t ** q = option + strlen(option) - 1; if (*q != ')') { - fr_strerror_printf("Alternate syntax is not properly terminated"); + fr_strerror_const("Alternate syntax is not properly terminated"); return -1; } @@ -696,7 +696,7 @@ static int fr_command_add_syntax(TALLOC_CTX *ctx, char *syntax, fr_cmd_argv_t ** } if (*p) { - fr_strerror_printf("Too many arguments passed in syntax string"); + fr_strerror_const("Too many arguments passed in syntax string"); return -1; } @@ -729,12 +729,12 @@ int fr_command_add(TALLOC_CTX *talloc_ctx, fr_cmd_t **head, char const *name, vo * This is a place-holder for tab expansion. */ if (!table->name) { - fr_strerror_printf("A name MUST be specified."); + fr_strerror_const("A name MUST be specified."); return -1; } if (!name && table->add_name) { - fr_strerror_printf("An additional name must be specified"); + fr_strerror_const("An additional name must be specified"); return -1; } @@ -783,7 +783,7 @@ int fr_command_add(TALLOC_CTX *talloc_ctx, fr_cmd_t **head, char const *name, vo } if (!cmd->intermediate) { - fr_strerror_printf("Cannot add a subcommand to a pre-existing command."); + fr_strerror_const("Cannot add a subcommand to a pre-existing command."); return -1; } @@ -873,13 +873,13 @@ int fr_command_add(TALLOC_CTX *talloc_ctx, fr_cmd_t **head, char const *name, vo */ if (argc == 0) { talloc_free(syntax); - fr_strerror_printf("Invalid empty string was supplied for syntax"); + fr_strerror_const("Invalid empty string was supplied for syntax"); return -1; } if ((depth + argc) >= CMD_MAX_ARGV) { talloc_free(syntax); - fr_strerror_printf("Too many arguments were supplied to the command."); + fr_strerror_const("Too many arguments were supplied to the command."); return -1; } } @@ -1020,7 +1020,7 @@ int fr_command_walk(fr_cmd_t *head, void **walk_ctx, void *ctx, fr_cmd_walk_t ca fr_cmd_walk_info_t info; if (!walk_ctx || !callback) { - fr_strerror_printf("No walk_ctx or callback specified"); + fr_strerror_const("No walk_ctx or callback specified"); return -1; } @@ -1923,7 +1923,7 @@ static int syntax_str_to_argv(int start_argc, fr_cmd_argv_t *start, fr_cmd_info_ p = skip_word(word); if (!p) { - fr_strerror_printf("Invalid string"); + fr_strerror_const("Invalid string"); return -1; } @@ -1957,7 +1957,7 @@ static int syntax_str_to_argv(int start_argc, fr_cmd_argv_t *start, fr_cmd_info_ type = argv->type; if (!info->box) { - fr_strerror_printf("No array defined for values"); + fr_strerror_const("No array defined for values"); return -1; } @@ -2092,7 +2092,7 @@ static int syntax_str_to_argv(int start_argc, fr_cmd_argv_t *start, fr_cmd_info_ /* * Not done yet! */ - fr_strerror_printf("Internal sanity check failed"); + fr_strerror_const("Internal sanity check failed"); return -1; next: @@ -2138,12 +2138,12 @@ int fr_command_str_to_argv(fr_cmd_t *head, fr_cmd_info_t *info, char const *text fr_cmd_t *cmd; if ((info->argc < 0) || (info->max_argc <= 0)) { - fr_strerror_printf("argc / max_argc must be greater than zero"); + fr_strerror_const("argc / max_argc must be greater than zero"); return -1; } if (!text) { - fr_strerror_printf("No string to split."); + fr_strerror_const("No string to split."); return -1; } @@ -2151,7 +2151,7 @@ int fr_command_str_to_argv(fr_cmd_t *head, fr_cmd_info_t *info, char const *text * Must have something to check. */ if (!head) { - fr_strerror_printf("No commands to parse."); + fr_strerror_const("No commands to parse."); return -1; } @@ -2258,7 +2258,7 @@ skip_matched: if (!MATCHED_NAME) { if (argc < info->argc) { invalid: - fr_strerror_printf("Invalid internal state"); + fr_strerror_const("Invalid internal state"); return -1; } @@ -2301,7 +2301,7 @@ skip_matched: if (argc == info->max_argc) { too_many: - fr_strerror_printf("Too many arguments for command."); + fr_strerror_const("Too many arguments for command."); return -1; } @@ -2365,7 +2365,7 @@ int fr_command_clear(int new_argc, fr_cmd_info_t *info) if ((new_argc < 0) || (new_argc >= CMD_MAX_ARGV) || (new_argc > info->argc)) { - fr_strerror_printf("Invalid argument"); + fr_strerror_const("Invalid argument"); return -1; } diff --git a/src/lib/server/cond_tokenize.c b/src/lib/server/cond_tokenize.c index 66841603032..a78a753e34d 100644 --- a/src/lib/server/cond_tokenize.c +++ b/src/lib/server/cond_tokenize.c @@ -254,7 +254,7 @@ static ssize_t cond_check_cast(fr_cond_t *c, char const *start, #ifdef HAVE_REGEX if (tmpl_contains_regex(c->data.map->rhs)) { - fr_strerror_printf("Cannot use cast with regex comparison"); + fr_strerror_const("Cannot use cast with regex comparison"); return -(rhs - start); } #endif @@ -265,7 +265,7 @@ static ssize_t cond_check_cast(fr_cond_t *c, char const *start, */ if (tmpl_is_unresolved(c->data.map->lhs) && (tmpl_cast_in_place(c->data.map->lhs, c->cast->type, c->cast) < 0)) { - fr_strerror_printf("Failed to parse field"); + fr_strerror_const("Failed to parse field"); return -(lhs - start); } @@ -276,7 +276,7 @@ static ssize_t cond_check_cast(fr_cond_t *c, char const *start, if ((tmpl_is_data(c->data.map->lhs)) && (tmpl_is_unresolved(c->data.map->rhs)) && (tmpl_cast_in_place(c->data.map->rhs, c->cast->type, c->cast) < 0)) { - fr_strerror_printf("Failed to parse field"); + fr_strerror_const("Failed to parse field"); return -(rhs - start); } @@ -342,7 +342,7 @@ static ssize_t cond_check_cast(fr_cond_t *c, char const *start, */ if ((dict_attr_sizes[c->cast->type][1] < dict_attr_sizes[tmpl_da(c->data.map->lhs)->type][0]) || (dict_attr_sizes[c->cast->type][0] > dict_attr_sizes[tmpl_da(c->data.map->lhs)->type][1])) { - fr_strerror_printf("Cannot cast to attribute of incompatible size"); + fr_strerror_const("Cannot cast to attribute of incompatible size"); return 0; } } @@ -414,7 +414,7 @@ static ssize_t cond_check_attrs(fr_cond_t *c, fr_sbuff_marker_t *m_lhs, fr_sbuff } if (tmpl_cast_in_place(data, type, tmpl_da(attr)) < 0) { - fr_strerror_printf_push("Failed casting data to match attribute"); + fr_strerror_const_push("Failed casting data to match attribute"); return -(data == lhs ? fr_sbuff_used(m_lhs) : fr_sbuff_used(m_rhs)); } } @@ -439,7 +439,7 @@ static ssize_t cond_check_attrs(fr_cond_t *c, fr_sbuff_marker_t *m_lhs, fr_sbuff */ if (c->cast && tmpl_is_unresolved(rhs) && (tmpl_cast_in_place(rhs, c->cast->type, c->cast) < 0)) { - fr_strerror_printf("Failed to parse field"); + fr_strerror_const("Failed to parse field"); return -fr_sbuff_used(m_rhs); } @@ -471,7 +471,7 @@ static ssize_t cond_check_attrs(fr_cond_t *c, fr_sbuff_marker_t *m_lhs, fr_sbuff (op != T_OP_CMP_TRUE) && (op != T_OP_CMP_FALSE) && (vpt->quote == T_BARE_WORD)) { - fr_strerror_printf("Comparison value must be a quoted string"); + fr_strerror_const("Comparison value must be a quoted string"); TMPL_RETURN(vpt); } @@ -515,7 +515,7 @@ static ssize_t cond_check_attrs(fr_cond_t *c, fr_sbuff_marker_t *m_lhs, fr_sbuff default: if (!attr->data.attribute.was_oid) { - fr_strerror_printf("Failed to parse value for attribute"); + fr_strerror_const("Failed to parse value for attribute"); TMPL_RETURN(vpt); } /* @@ -525,7 +525,7 @@ static ssize_t cond_check_attrs(fr_cond_t *c, fr_sbuff_marker_t *m_lhs, fr_sbuff tmpl_attr_to_raw(attr); if (tmpl_cast_in_place(vpt, tmpl_da(attr)->type, c->cast ? NULL : tmpl_da(attr)) < 0) { - fr_strerror_printf("Failed to parse value for attribute"); + fr_strerror_const("Failed to parse value for attribute"); TMPL_RETURN(vpt); } break; @@ -539,7 +539,7 @@ static ssize_t cond_check_attrs(fr_cond_t *c, fr_sbuff_marker_t *m_lhs, fr_sbuff */ if (tmpl_da(attr)->type == FR_TYPE_COMBO_IP_ADDR) { if (tmpl_attr_abstract_to_concrete(attr, tmpl_value_type(vpt)) < 0) { - fr_strerror_printf("Cannot find type for attribute"); + fr_strerror_const("Cannot find type for attribute"); TMPL_RETURN(attr); } } @@ -846,7 +846,7 @@ static int cond_normalise(TALLOC_CTX *ctx, fr_token_t lhs_type, fr_cond_t **c_ou break; default: - fr_strerror_printf("Internal sanity check failed 1"); + fr_strerror_const("Internal sanity check failed 1"); return -1; } @@ -945,7 +945,7 @@ static int cond_normalise(TALLOC_CTX *ctx, fr_token_t lhs_type, fr_cond_t **c_ou rcode = fr_table_value_by_str(allowed_return_codes, c->data.vpt->name, 0); if (!rcode) { - fr_strerror_printf("Expected a module return code"); + fr_strerror_const("Expected a module return code"); return -1; } } @@ -1051,7 +1051,7 @@ static int cond_normalise(TALLOC_CTX *ctx, fr_token_t lhs_type, fr_cond_t **c_ou static int cond_forbid_groups(tmpl_t *vpt, fr_sbuff_t *in, fr_sbuff_marker_t *m_lhs) { if (tmpl_is_list(vpt)) { - fr_strerror_printf("Cannot use list references in condition"); + fr_strerror_const("Cannot use list references in condition"); fr_sbuff_set(in, m_lhs); return -1; } @@ -1143,7 +1143,7 @@ static ssize_t cond_tokenize_operand(TALLOC_CTX *ctx, tmpl_t **out, break; #ifndef HAVE_REGEX case T_SOLIDUS_QUOTED_STRING: - fr_strerror_printf("Compiled without support for regexes"); + fr_strerror_const("Compiled without support for regexes"); fr_sbuff_set(&our_in, &m); fr_sbuff_advance(&our_in, 1); goto error; @@ -1160,7 +1160,7 @@ static ssize_t cond_tokenize_operand(TALLOC_CTX *ctx, tmpl_t **out, } if ((type != T_BARE_WORD) && !fr_sbuff_next_if_char(&our_in, fr_token_quote[type])) { /* Quoting */ - fr_strerror_printf("Unterminated string"); + fr_strerror_const("Unterminated string"); fr_sbuff_set(&our_in, &m); fr_sbuff_advance(&our_in, 1); goto error; @@ -1176,7 +1176,7 @@ static ssize_t cond_tokenize_operand(TALLOC_CTX *ctx, tmpl_t **out, */ if (type == T_SOLIDUS_QUOTED_STRING) { if (!tmpl_contains_regex(vpt)) { - fr_strerror_printf("Expected regex"); + fr_strerror_const("Expected regex"); fr_sbuff_set(&our_in, &m); goto error; } @@ -1255,7 +1255,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, fr_cond_t **out, fr_sbuff_adv_past_whitespace(&our_in, SIZE_MAX); if (!fr_sbuff_extend(&our_in)) { - fr_strerror_printf("Empty condition is invalid"); + fr_strerror_const("Empty condition is invalid"); error: talloc_free(c); return -(fr_sbuff_used_total(&our_in)); @@ -1272,7 +1272,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, fr_cond_t **out, * Just for stupidity */ if (fr_sbuff_is_char(&our_in, '!')) { - fr_strerror_printf("Double negation is invalid"); + fr_strerror_const("Double negation is invalid"); goto error; } } @@ -1296,7 +1296,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, fr_cond_t **out, } if (!c->data.child) { - fr_strerror_printf("Empty condition is invalid"); + fr_strerror_const("Empty condition is invalid"); goto error; } @@ -1344,7 +1344,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, fr_cond_t **out, */ if (fr_sbuff_is_char(&our_in, ')')) { if (fr_sbuff_used_total(&our_in) == 0) { - fr_strerror_printf("Empty string is invalid"); + fr_strerror_const("Empty string is invalid"); goto error; } @@ -1358,7 +1358,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, fr_cond_t **out, */ } else if (!fr_sbuff_extend(&our_in)) { if (brace) { - fr_strerror_printf("Missing closing brace"); + fr_strerror_const("Missing closing brace"); goto error; } @@ -1372,13 +1372,13 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, fr_cond_t **out, if ((cond_op == COND_AND) || (cond_op == COND_OR)) { unary: if (c->cast) { - fr_strerror_printf("Cannot do cast for existence check"); + fr_strerror_const("Cannot do cast for existence check"); fr_sbuff_set(&our_in, &m_lhs_cast); goto error; } if (tmpl_contains_regex(lhs)) { - fr_strerror_printf("Unexpected regular expression"); + fr_strerror_const("Unexpected regular expression"); fr_sbuff_set(&our_in, &m_lhs); goto error; } @@ -1398,7 +1398,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, fr_cond_t **out, rcode = fr_table_value_by_str(rcode_table, lhs->data.unescaped, RLM_MODULE_UNKNOWN); if (rcode == RLM_MODULE_UNKNOWN) { - fr_strerror_printf("Expected a module return code"); + fr_strerror_const("Expected a module return code"); fr_sbuff_set(&our_in, &m_lhs); goto error; } @@ -1430,7 +1430,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, fr_cond_t **out, fr_sbuff_marker(&m_op, &our_in); fr_sbuff_out_by_longest_prefix(&slen, &op, cond_cmp_op_table, &our_in, 0); if (slen == 0) { - fr_strerror_printf("Invalid operator"); + fr_strerror_const("Invalid operator"); goto error; } fr_sbuff_adv_past_whitespace(&our_in, SIZE_MAX); @@ -1466,7 +1466,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, fr_cond_t **out, } if (!fr_sbuff_extend(&our_in)) { - fr_strerror_printf("Expected text after operator"); + fr_strerror_const("Expected text after operator"); goto error; } @@ -1496,21 +1496,21 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, fr_cond_t **out, }; if (rhs->cast != FR_TYPE_INVALID) { - fr_strerror_printf("Unexpected cast"); + fr_strerror_const("Unexpected cast"); fr_sbuff_set(&our_in, &m_rhs_cast); goto error; } if (((op == T_OP_REG_EQ) || (op == T_OP_REG_NE)) && (!tmpl_contains_regex(lhs) && !tmpl_contains_regex(rhs))) { - fr_strerror_printf("Expected regular expression"); + fr_strerror_const("Expected regular expression"); fr_sbuff_set(&our_in, &m_rhs); goto error; } if (((op != T_OP_REG_EQ) && (op != T_OP_REG_NE)) && (tmpl_contains_regex(lhs) || tmpl_contains_regex(rhs))) { - fr_strerror_printf("Unexpected regular expression"); /* Fixme should point to correct operand */ + fr_strerror_const("Unexpected regular expression"); /* Fixme should point to correct operand */ fr_sbuff_set(&our_in, &m_rhs); goto error; } @@ -1544,7 +1544,7 @@ closing_brace: */ if (fr_sbuff_is_char(&our_in, ')')) { if (!brace) { - fr_strerror_printf("Unexpected closing brace"); + fr_strerror_const("Unexpected closing brace"); goto error; } fr_sbuff_advance(&our_in, 1); @@ -1558,7 +1558,7 @@ closing_brace: */ if (!fr_sbuff_extend(&our_in)) { if (brace) { - fr_strerror_printf("Missing closing brace"); + fr_strerror_const("Missing closing brace"); goto error; } goto done; @@ -1582,7 +1582,7 @@ closing_brace: fr_sbuff_out_by_longest_prefix(&slen, &cond_op, cond_logical_op_table, &our_in, COND_NONE); if (slen == 0) { - fr_strerror_printf("Unexpected text after condition"); + fr_strerror_const("Unexpected text after condition"); goto error; } @@ -1629,7 +1629,7 @@ ssize_t fr_cond_tokenize(CONF_SECTION *cs, fr_cond_t **head, tmpl_rules_t const if (!cf_expand_variables(cf_filename(cs), cf_lineno(cs), cf_item_to_section(cf_parent(cs)), buffer, sizeof(buffer), fr_sbuff_current(in), fr_sbuff_remaining(in), NULL)) { - fr_strerror_printf("Failed expanding configuration variable"); + fr_strerror_const("Failed expanding configuration variable"); return 0; } diff --git a/src/lib/server/exec.c b/src/lib/server/exec.c index cb6bceaba18..9acde534aaf 100644 --- a/src/lib/server/exec.c +++ b/src/lib/server/exec.c @@ -747,7 +747,7 @@ int fr_exec_wait_start(request_t *request, fr_value_box_t *vb, fr_pair_list_t *e if (input_fd) { if (pipe(to_child) < 0) { error2: - fr_strerror_printf_push("Failed opening pipe to read to child"); + fr_strerror_const_push("Failed opening pipe to read to child"); talloc_free(argv); goto error; } diff --git a/src/lib/server/exfile.c b/src/lib/server/exfile.c index 2bbb225b7b1..919c830cc6c 100644 --- a/src/lib/server/exfile.c +++ b/src/lib/server/exfile.c @@ -553,6 +553,6 @@ int exfile_close(exfile_t *ef, request_t *request, int fd) pthread_mutex_unlock(&(ef->mutex)); - fr_strerror_printf("Attempt to unlock file which is not tracked"); + fr_strerror_const("Attempt to unlock file which is not tracked"); return -1; } diff --git a/src/lib/server/main_config.c b/src/lib/server/main_config.c index 799b9d3b076..2cf5f0b95ed 100644 --- a/src/lib/server/main_config.c +++ b/src/lib/server/main_config.c @@ -859,7 +859,7 @@ main_config_t *main_config_alloc(TALLOC_CTX *ctx) config = talloc_zero(ctx, main_config_t); if (!config) { - fr_strerror_printf("Failed allocating main config"); + fr_strerror_const("Failed allocating main config"); return NULL; } diff --git a/src/lib/server/map.c b/src/lib/server/map.c index dca59082346..2ae5b031f5b 100644 --- a/src/lib/server/map.c +++ b/src/lib/server/map.c @@ -341,7 +341,7 @@ int map_afrom_sbuff(TALLOC_CTX *ctx, map_t **out, fr_sbuff_t *in, */ if (token != T_BARE_WORD) { if (!fr_sbuff_is_char(&sbuff, fr_token_quote[token])) { - fr_strerror_printf("Unexpected end of quoted string"); + fr_strerror_const("Unexpected end of quoted string"); return -1; } @@ -357,7 +357,7 @@ int map_afrom_sbuff(TALLOC_CTX *ctx, map_t **out, fr_sbuff_t *in, slen = fr_sbuff_adv_past_whitespace(&sbuff, SIZE_MAX); if (slen < 0) { - fr_strerror_printf("Unexpected end of string after parsing left side"); + fr_strerror_const("Unexpected end of string after parsing left side"); goto error; } @@ -366,13 +366,13 @@ int map_afrom_sbuff(TALLOC_CTX *ctx, map_t **out, fr_sbuff_t *in, */ fr_sbuff_out_by_longest_prefix(&slen, &map->op, op_table, &sbuff, 0); if (slen <= 0) { - fr_strerror_printf("Invalid operator"); + fr_strerror_const("Invalid operator"); goto error; } slen = fr_sbuff_adv_past_whitespace(&sbuff, SIZE_MAX); if (slen < 0) { - fr_strerror_printf("Unexpected end of string after operator"); + fr_strerror_const("Unexpected end of string after operator"); goto error; } @@ -404,7 +404,7 @@ int map_afrom_sbuff(TALLOC_CTX *ctx, map_t **out, fr_sbuff_t *in, if (slen < 0) goto error; if (slen == 0) { - fr_strerror_printf("Unexpected end of input after operator"); + fr_strerror_const("Unexpected end of input after operator"); goto error; } fr_assert(map->rhs != NULL); @@ -414,7 +414,7 @@ int map_afrom_sbuff(TALLOC_CTX *ctx, map_t **out, fr_sbuff_t *in, */ if (token != T_BARE_WORD) { if (!fr_sbuff_is_char(&sbuff, fr_token_quote[token])) { - fr_strerror_printf("Unexpected end of quoted string"); + fr_strerror_const("Unexpected end of quoted string"); return -1; } @@ -720,7 +720,7 @@ int map_afrom_attr_str(TALLOC_CTX *ctx, map_t **out, char const *vp_str, if (!tmpl_is_attr((*out)->lhs)) { TALLOC_FREE(*out); - fr_strerror_printf("Left operand must be an attribute"); + fr_strerror_const("Left operand must be an attribute"); return -1; } @@ -746,7 +746,7 @@ int map_afrom_vp(TALLOC_CTX *ctx, map_t **out, fr_pair_t *vp, tmpl_rules_t const map = map_alloc(ctx); if (!map) { oom: - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } diff --git a/src/lib/server/snmp.c b/src/lib/server/snmp.c index 54a83333ec0..1605b77e971 100644 --- a/src/lib/server/snmp.c +++ b/src/lib/server/snmp.c @@ -539,7 +539,7 @@ static ssize_t snmp_process_index(fr_cursor_t *out, request_t *request, tmp_ctx = talloc_new(request); if (!tmp_ctx) { - fr_strerror_printf("Out Of Memory"); + fr_strerror_const("Out Of Memory"); return -(depth); } @@ -553,7 +553,7 @@ static ssize_t snmp_process_index(fr_cursor_t *out, request_t *request, if (snmp_op != FR_FREERADIUS_SNMP_OPERATION_VALUE_GETNEXT) { invalid: - fr_strerror_printf("Invalid OID: Match stopped here"); + fr_strerror_const("Invalid OID: Match stopped here"); return -(depth); } @@ -603,7 +603,7 @@ static ssize_t snmp_process_index(fr_cursor_t *out, request_t *request, return 0; /* done */ } - fr_strerror_printf("Invalid OID: Hit max index"); + fr_strerror_const("Invalid OID: Hit max index"); return -(depth); } @@ -620,13 +620,13 @@ static ssize_t snmp_process_index_attr(fr_cursor_t *out, request_t *request, FR_PROTO_STACK_PRINT(da_stack, depth); if (map[0].last < &map[1]) { - fr_strerror_printf("Invalid OID: Empty map"); + fr_strerror_const("Invalid OID: Empty map"); error: return -(ssize_t)depth; } if (map[1].type != FR_FREERADIUS_SNMP_TYPE_OBJECT) { - fr_strerror_printf("Invalid OID: Cannot traverse leaf"); + fr_strerror_const("Invalid OID: Cannot traverse leaf"); goto error; } @@ -684,13 +684,13 @@ static ssize_t snmp_process_tlv(fr_cursor_t *out, request_t *request, map_p = snmp_map_search(map, da_stack->da[depth]); if (!map_p) { invalid: - fr_strerror_printf("Invalid OID: Match stopped here"); + fr_strerror_const("Invalid OID: Match stopped here"); error: return -(ssize_t)depth; } if (!map_p->child) { - fr_strerror_printf("Internal error: Dictionary and SNMP map structure mismatch"); + fr_strerror_const("Internal error: Dictionary and SNMP map structure mismatch"); goto error; } @@ -747,7 +747,7 @@ static ssize_t snmp_process_leaf(fr_cursor_t *out, request_t *request, */ map_p = snmp_map_search(map, da_stack->da[depth]); if (!map_p) { - fr_strerror_printf("Invalid OID: Match stopped here"); + fr_strerror_const("Invalid OID: Match stopped here"); error: return -(ssize_t)depth; } @@ -786,12 +786,12 @@ static ssize_t snmp_process_leaf(fr_cursor_t *out, request_t *request, * Verify map is a leaf */ if (map_p->type == FR_FREERADIUS_SNMP_TYPE_OBJECT) { - fr_strerror_printf("Invalid OID: Is not a leaf node"); + fr_strerror_const("Invalid OID: Is not a leaf node"); goto error; } if (!map_p->get) { - fr_strerror_printf("Invalid operation: Node does not support GET operations"); + fr_strerror_const("Invalid operation: Node does not support GET operations"); goto error; } @@ -883,7 +883,7 @@ static ssize_t snmp_process(fr_cursor_t *out, request_t *request, */ if (!da_stack->da[depth]) { if (snmp_op != FR_FREERADIUS_SNMP_OPERATION_VALUE_GETNEXT) { - fr_strerror_printf("Invalid OID: Not a leaf"); + fr_strerror_const("Invalid OID: Not a leaf"); return -(ssize_t)(depth - 1); } snmp_next_leaf(da_stack, depth, &map[1]); diff --git a/src/lib/server/tmpl_eval.c b/src/lib/server/tmpl_eval.c index ef90c596c4a..2903c3b3447 100644 --- a/src/lib/server/tmpl_eval.c +++ b/src/lib/server/tmpl_eval.c @@ -306,7 +306,7 @@ ssize_t _tmpl_to_type(void *out, { RDEBUG4("EXPAND TMPL EXEC"); if (!buff) { - fr_strerror_printf("Missing expansion buffer for EXEC"); + fr_strerror_const("Missing expansion buffer for EXEC"); return -1; } @@ -324,7 +324,7 @@ ssize_t _tmpl_to_type(void *out, RDEBUG4("EXPAND TMPL XLAT PARSED"); RDEBUG2("EXPAND %s", vpt->name); /* xlat_struct doesn't do this */ if (!buff) { - fr_strerror_printf("Missing expansion buffer for XLAT_STRUCT"); + fr_strerror_const("Missing expansion buffer for XLAT_STRUCT"); return -1; } /* Error in expansion, this is distinct from zero length expansion */ @@ -408,7 +408,7 @@ ssize_t _tmpl_to_type(void *out, */ case FR_TYPE_STRING: if (!buff) { - fr_strerror_printf("Missing expansion buffer for octet->string cast"); + fr_strerror_const("Missing expansion buffer for octet->string cast"); return -1; } if (bufflen <= to_cast->vb_length) { @@ -468,7 +468,7 @@ ssize_t _tmpl_to_type(void *out, switch (dst_type) { case FR_TYPE_STRING: if (!buff) { - fr_strerror_printf("Missing expansion buffer to store cast output"); + fr_strerror_const("Missing expansion buffer to store cast output"); error: talloc_free(ctx); return -1; @@ -488,7 +488,7 @@ ssize_t _tmpl_to_type(void *out, case FR_TYPE_OCTETS: if (!buff) { - fr_strerror_printf("Missing expansion buffer to store cast output"); + fr_strerror_const("Missing expansion buffer to store cast output"); goto error; } if (from_cast->vb_length > bufflen) { @@ -1340,7 +1340,7 @@ int tmpl_copy_pairs(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, tm vp = fr_pair_copy(ctx, vp); if (!vp) { fr_pair_list_free(out); - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); err = -4; break; } diff --git a/src/lib/server/tmpl_tokenize.c b/src/lib/server/tmpl_tokenize.c index 692c17eb6c0..be8aac6228c 100644 --- a/src/lib/server/tmpl_tokenize.c +++ b/src/lib/server/tmpl_tokenize.c @@ -832,7 +832,7 @@ int tmpl_attr_set_leaf_da(tmpl_t *vpt, fr_dict_attr_t const *da) parent = fr_dlist_prev(&vpt->data.attribute.ar, ref); if (!fr_dict_attr_common_parent(parent->ar_da, da, true)) { - fr_strerror_printf("New leaf da and old leaf da do not share the same ancestor"); + fr_strerror_const("New leaf da and old leaf da do not share the same ancestor"); return -1; } } else { @@ -1203,13 +1203,13 @@ static tmpl_attr_filter_t tmpl_attr_parse_filter(tmpl_attr_error_t *err, tmpl_at if (fr_sbuff_out(&sberr, &ar->num, &tmp) == 0) { if (sberr == FR_SBUFF_PARSE_ERROR_NOT_FOUND) { - fr_strerror_printf("Invalid array index"); + fr_strerror_const("Invalid array index"); if (err) *err = TMPL_ATTR_ERROR_INVALID_ARRAY_INDEX; error: return TMPL_ATTR_REF_BAD_FILTER; } - fr_strerror_printf("Invalid array index"); + fr_strerror_const("Invalid array index"); if (err) *err = TMPL_ATTR_ERROR_INVALID_ARRAY_INDEX; goto error; } @@ -1230,7 +1230,7 @@ static tmpl_attr_filter_t tmpl_attr_parse_filter(tmpl_attr_error_t *err, tmpl_at * marker points to the bad char. */ if (!fr_sbuff_next_if_char(name, ']')) { - fr_strerror_printf("No closing ']' for array index"); + fr_strerror_const("No closing ']' for array index"); if (err) *err = TMPL_ATTR_ERROR_INVALID_ARRAY_INDEX; goto error; } @@ -1269,7 +1269,7 @@ int tmpl_attr_afrom_attr_unresolved_substr(TALLOC_CTX *ctx, tmpl_attr_error_t *e size_t len; if (depth > FR_DICT_MAX_TLV_STACK) { - fr_strerror_printf("Attribute nesting too deep"); + fr_strerror_const("Attribute nesting too deep"); if (err) *err = TMPL_ATTR_ERROR_NESTING_TOO_DEEP; return -1; } @@ -1278,7 +1278,7 @@ int tmpl_attr_afrom_attr_unresolved_substr(TALLOC_CTX *ctx, tmpl_attr_error_t *e * Input too short */ if (!fr_sbuff_extend(name)) { - fr_strerror_printf("Missing attribute reference"); + fr_strerror_const("Missing attribute reference"); if (err) *err = TMPL_ATTR_ERROR_INVALID_NAME; return -1; } @@ -1300,14 +1300,14 @@ int tmpl_attr_afrom_attr_unresolved_substr(TALLOC_CTX *ctx, tmpl_attr_error_t *e name, FR_DICT_ATTR_MAX_NAME_LEN + 1, fr_dict_attr_allowed_chars); if (len == 0) { - fr_strerror_printf("Invalid attribute name"); + fr_strerror_const("Invalid attribute name"); if (err) *err = TMPL_ATTR_ERROR_INVALID_NAME; error: talloc_free(ar); return -1; } if (len > FR_DICT_ATTR_MAX_NAME_LEN) { - fr_strerror_printf("Attribute name is too long"); + fr_strerror_const("Attribute name is too long"); if (err) *err = TMPL_ATTR_ERROR_INVALID_NAME; goto error; } @@ -1389,7 +1389,7 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t fr_sbuff_marker(&m_s, name); if (depth > FR_DICT_MAX_TLV_STACK) { - fr_strerror_printf("Attribute nesting too deep"); + fr_strerror_const("Attribute nesting too deep"); if (err) *err = TMPL_ATTR_ERROR_NESTING_TOO_DEEP; error: fr_sbuff_marker_release(&m_s); @@ -1400,7 +1400,7 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t * Input too short */ if (!fr_sbuff_extend(name)) { - fr_strerror_printf("Missing attribute reference"); + fr_strerror_const("Missing attribute reference"); if (err) *err = TMPL_ATTR_ERROR_INVALID_NAME; goto error; } @@ -1500,7 +1500,7 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t if (!namespace && t_rules->dict_def) parent = namespace = fr_dict_root(t_rules->dict_def); if (!namespace && !t_rules->disallow_internal) parent = namespace = fr_dict_root(fr_dict_internal()); if (!namespace) { - fr_strerror_printf("Attribute references must be qualified with a protocol when used here"); + fr_strerror_const("Attribute references must be qualified with a protocol when used here"); if (err) *err = TMPL_ATTR_ERROR_UNQUALIFIED_NOT_ALLOWED; fr_sbuff_set(name, &m_s); goto error; @@ -1542,7 +1542,7 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t } if (!t_rules->allow_unknown) { - fr_strerror_printf("Unknown attributes not allowed here"); + fr_strerror_const("Unknown attributes not allowed here"); if (err) *err = TMPL_ATTR_ERROR_UNKNOWN_NOT_ALLOWED; fr_sbuff_set(name, &m_s); goto error; @@ -1589,7 +1589,7 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t * errors from the dictionary code. */ if (!t_rules->allow_unresolved) { - fr_strerror_printf_push("Unresolved attributes not allowed here"); + fr_strerror_const_push("Unresolved attributes not allowed here"); if (err) *err = TMPL_ATTR_ERROR_UNRESOLVED_NOT_ALLOWED; fr_sbuff_set(name, &m_s); goto error; @@ -1622,7 +1622,7 @@ check_attr: * true, we still allow the resolution. */ if (t_rules->disallow_internal && (found_in == fr_dict_internal())) { - fr_strerror_printf("Internal attributes not allowed here"); + fr_strerror_const("Internal attributes not allowed here"); if (err) *err = TMPL_ATTR_ERROR_INTERNAL_NOT_ALLOWED; fr_sbuff_set(name, &m_s); goto error; @@ -1806,13 +1806,13 @@ static inline int tmpl_request_ref_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_ * Nesting level too deep */ if (depth > TMPL_MAX_REQUEST_REF_NESTING) { - fr_strerror_printf("Request ref nesting too deep"); + fr_strerror_const("Request ref nesting too deep"); if (err) *err = TMPL_ATTR_ERROR_NESTING_TOO_DEEP; return -1; } if (t_rules->attr_parent || t_rules->disallow_qualifiers) { - fr_strerror_printf("It is not permitted to specify a request reference here"); + fr_strerror_const("It is not permitted to specify a request reference here"); if (err) *err = TMPL_ATTR_ERROR_INVALID_LIST_QUALIFIER; return -1; } @@ -1900,7 +1900,7 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t *err, if (err) *err = TMPL_ATTR_ERROR_NONE; if (!fr_sbuff_extend(&our_name)) { - fr_strerror_printf("Empty attribute reference"); + fr_strerror_const("Empty attribute reference"); if (err) *err = TMPL_ATTR_ERROR_EMPTY; FR_SBUFF_ERROR_RETURN(&our_name); } @@ -1911,7 +1911,7 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t *err, switch (t_rules->prefix) { case TMPL_ATTR_REF_PREFIX_YES: if (!fr_sbuff_next_if_char(&our_name, '&')) { - fr_strerror_printf("Invalid attribute reference, missing '&' prefix"); + fr_strerror_const("Invalid attribute reference, missing '&' prefix"); if (err) *err = TMPL_ATTR_ERROR_BAD_PREFIX; FR_SBUFF_ERROR_RETURN(&our_name); } @@ -1920,7 +1920,7 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t *err, case TMPL_ATTR_REF_PREFIX_NO: if (fr_sbuff_is_char(&our_name, '&')) { - fr_strerror_printf("Attribute references used here must not have a '&' prefix"); + fr_strerror_const("Attribute references used here must not have a '&' prefix"); if (err) *err = TMPL_ATTR_ERROR_BAD_PREFIX; FR_SBUFF_ERROR_RETURN(&our_name); } @@ -1962,7 +1962,7 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t *err, &our_name, t_rules->list_def); if ((t_rules->attr_parent || t_rules->disallow_qualifiers) && (list_len > 0)) { - fr_strerror_printf("It is not permitted to specify a pair list here"); + fr_strerror_const("It is not permitted to specify a pair list here"); if (err) *err = TMPL_ATTR_ERROR_INVALID_LIST_QUALIFIER; talloc_free(vpt); FR_SBUFF_ERROR_RETURN(&our_name); @@ -2025,7 +2025,7 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t *err, vpt->rules = *t_rules; /* Record the rules */ if (!tmpl_substr_terminal_check(&our_name, p_rules)) { - fr_strerror_printf("Unexpected text after attribute reference"); + fr_strerror_const("Unexpected text after attribute reference"); if (err) *err = TMPL_ATTR_ERROR_MISSING_TERMINATOR; talloc_free(vpt); *out = NULL; @@ -2095,12 +2095,12 @@ static ssize_t tmpl_afrom_bool_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t tmpl_t *vpt; if (!fr_sbuff_out(NULL, &a_bool, &our_in)) { - fr_strerror_printf("Not a boolean value"); + fr_strerror_const("Not a boolean value"); return 0; } if (!tmpl_substr_terminal_check(&our_in, p_rules)) { - fr_strerror_printf("Unexpected text after bool"); + fr_strerror_const("Unexpected text after bool"); return -fr_sbuff_used(in); } @@ -2145,18 +2145,18 @@ static ssize_t tmpl_afrom_octets_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_ */ len = fr_sbuff_out_abstrncpy_allowed(vpt, &hex, &our_in, SIZE_MAX, sbuff_char_class_hex); if (len & 0x01) { - fr_strerror_printf("Hex string not even length"); + fr_strerror_const("Hex string not even length"); error: talloc_free(vpt); return -fr_sbuff_used(&our_in); } if (len == 0) { - fr_strerror_printf("Zero length hex string is invalid"); + fr_strerror_const("Zero length hex string is invalid"); goto error; } if (!tmpl_substr_terminal_check(&our_in, p_rules)) { - fr_strerror_printf("Unexpected text after hex string"); + fr_strerror_const("Unexpected text after hex string"); goto error; } @@ -2211,12 +2211,12 @@ static ssize_t tmpl_afrom_ipv4_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t */ if (fr_sbuff_next_if_char(&our_in, '/')) { if (!fr_sbuff_out(NULL, &octet, &our_in)) { - fr_strerror_printf("IPv4 CIDR mask malformed"); + fr_strerror_const("IPv4 CIDR mask malformed"); goto error; } if (octet > 32) { - fr_strerror_printf("IPv4 CIDR mask too high"); + fr_strerror_const("IPv4 CIDR mask too high"); goto error; } @@ -2226,7 +2226,7 @@ static ssize_t tmpl_afrom_ipv4_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t } if (!tmpl_substr_terminal_check(&our_in, p_rules)) { - fr_strerror_printf("Unexpected text after IPv4 string or prefix"); + fr_strerror_const("Unexpected text after IPv4 string or prefix"); goto error; } @@ -2296,7 +2296,7 @@ static ssize_t tmpl_afrom_ipv6_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t */ sep_a = memchr(fr_sbuff_current(&m), '.', len); if (sep_a && (!(sep_b = memchr(fr_sbuff_current(&m), ':', len)) || (sep_b > sep_a))) { - fr_strerror_printf("First IPv6 component separator was a '.'"); + fr_strerror_const("First IPv6 component separator was a '.'"); goto error; } @@ -2306,7 +2306,7 @@ static ssize_t tmpl_afrom_ipv6_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t */ sep_a = memchr(fr_sbuff_current(&m), ':', len); if (!sep_a) { - fr_strerror_printf("No IPv6 component separator"); + fr_strerror_const("No IPv6 component separator"); goto error; } @@ -2316,7 +2316,7 @@ static ssize_t tmpl_afrom_ipv6_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t if (fr_sbuff_next_if_char(&our_in, '%')) { len = fr_sbuff_adv_until(&our_in, IFNAMSIZ + 1, p_rules->terminals, '\0'); if ((len < 1) || (len > IFNAMSIZ)) { - fr_strerror_printf("IPv6 scope too long"); + fr_strerror_const("IPv6 scope too long"); goto error; } } @@ -2328,11 +2328,11 @@ static ssize_t tmpl_afrom_ipv6_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t uint8_t mask; if (!fr_sbuff_out(NULL, &mask, &our_in)) { - fr_strerror_printf("IPv6 CIDR mask malformed"); + fr_strerror_const("IPv6 CIDR mask malformed"); goto error; } if (mask > 128) { - fr_strerror_printf("IPv6 CIDR mask too high"); + fr_strerror_const("IPv6 CIDR mask too high"); goto error; } @@ -2342,7 +2342,7 @@ static ssize_t tmpl_afrom_ipv6_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t } if (!tmpl_substr_terminal_check(&our_in, p_rules)) { - fr_strerror_printf("Unexpected text after IPv6 string or prefix"); + fr_strerror_const("Unexpected text after IPv6 string or prefix"); goto error; } @@ -2385,7 +2385,7 @@ static ssize_t tmpl_afrom_integer_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff if (slen <= 0) return 0; if (!tmpl_substr_terminal_check(&our_in, p_rules)) { - fr_strerror_printf("Unexpected text after signed integer"); + fr_strerror_const("Unexpected text after signed integer"); error: return -fr_sbuff_used(&our_in); } @@ -2416,7 +2416,7 @@ static ssize_t tmpl_afrom_integer_substr(TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff if (slen <= 0) return slen; if (!tmpl_substr_terminal_check(&our_in, p_rules)) { - fr_strerror_printf("Unexpected text after unsigned integer"); + fr_strerror_const("Unexpected text after unsigned integer"); goto error; } @@ -2591,7 +2591,7 @@ ssize_t tmpl_afrom_substr(TALLOC_CTX *ctx, tmpl_t **out, p_rules ? p_rules->terminals : NULL, p_rules ? p_rules->escapes : NULL); if (slen == 0) { - fr_strerror_printf("Empty bareword is invalid"); + fr_strerror_const("Empty bareword is invalid"); talloc_free(vpt); return 0; } @@ -2756,15 +2756,15 @@ ssize_t tmpl_cast_from_substr(fr_type_t *out, fr_sbuff_t *in) fr_sbuff_marker(&m, &our_in); fr_sbuff_out_by_longest_prefix(&slen, &cast, fr_value_box_type_table, &our_in, FR_TYPE_INVALID); if (cast == FR_TYPE_INVALID) { - fr_strerror_printf("Unknown data type"); + fr_strerror_const("Unknown data type"); FR_SBUFF_ERROR_RETURN(&our_in); } if (fr_dict_non_data_types[cast]) { - fr_strerror_printf("Forbidden data type in cast"); + fr_strerror_const("Forbidden data type in cast"); FR_SBUFF_MARKER_ERROR_RETURN(&m); } if (!fr_sbuff_next_if_char(&our_in, '>')) { - fr_strerror_printf("Unterminated cast"); + fr_strerror_const("Unterminated cast"); FR_SBUFF_ERROR_RETURN(&our_in); } fr_sbuff_adv_past_whitespace(&our_in, SIZE_MAX); @@ -2785,7 +2785,7 @@ ssize_t tmpl_cast_from_substr(fr_type_t *out, fr_sbuff_t *in) int tmpl_cast_set(tmpl_t *vpt, fr_type_t type) { if (fr_dict_non_data_types[type]) { - fr_strerror_printf("Forbidden data type in cast"); + fr_strerror_const("Forbidden data type in cast"); return -1; } @@ -3338,7 +3338,7 @@ int tmpl_attr_unknown_add(tmpl_t *vpt) continue; case TMPL_ATTR_TYPE_UNRESOLVED: /* Shouldn't have been called */ - fr_strerror_printf("Remaining attributes are unresolved"); + fr_strerror_const("Remaining attributes are unresolved"); return -1; case TMPL_ATTR_TYPE_UNKNOWN: @@ -3385,7 +3385,7 @@ int tmpl_attr_unknown_add(tmpl_t *vpt) fr_dict_unknown_free(&ar->ar_da); ar->ar_da = known; } else if (!fr_cond_assert(!next)) { - fr_strerror_printf("Only the leaf may be raw"); + fr_strerror_const("Only the leaf may be raw"); return -1; } } diff --git a/src/lib/server/util.c b/src/lib/server/util.c index cb717477048..e494976c549 100644 --- a/src/lib/server/util.c +++ b/src/lib/server/util.c @@ -546,7 +546,7 @@ int rad_expand_xlat(request_t *request, char const *cmd, int left; if (strlen(cmd) > (argv_buflen - 1)) { - fr_strerror_printf("Expansion string is too long for output buffer"); + fr_strerror_const("Expansion string is too long for output buffer"); return -1; } @@ -554,7 +554,7 @@ int rad_expand_xlat(request_t *request, char const *cmd, * Check for bad escapes. */ if (cmd[strlen(cmd) - 1] == '\\') { - fr_strerror_printf("Expansion string ends with a trailing backslash - invalid escape sequence"); + fr_strerror_const("Expansion string ends with a trailing backslash - invalid escape sequence"); return -1; } @@ -581,7 +581,7 @@ int rad_expand_xlat(request_t *request, char const *cmd, */ while (*from && (*from != ' ') && (*from != '\t')) { if (to >= argv_buf + argv_buflen - 1) { - fr_strerror_printf("Expansion string is too long for output buffer"); + fr_strerror_const("Expansion string is too long for output buffer"); return -1; } @@ -590,7 +590,7 @@ int rad_expand_xlat(request_t *request, char const *cmd, case '\'': length = rad_copy_string_bare(to, from); if (length < 0) { - fr_strerror_printf("Invalid quoted string in expansion"); + fr_strerror_const("Invalid quoted string in expansion"); return -1; } from += length+2; @@ -603,7 +603,7 @@ int rad_expand_xlat(request_t *request, char const *cmd, length = rad_copy_variable(to, from); if (length < 0) { - fr_strerror_printf("Invalid variable in expansion"); + fr_strerror_const("Invalid variable in expansion"); return -1; } from += length; @@ -629,7 +629,7 @@ int rad_expand_xlat(request_t *request, char const *cmd, * We have to have SOMETHING, at least. */ if (argc <= 0) { - fr_strerror_printf("Expansion string is empty"); + fr_strerror_const("Expansion string is empty"); return -1; } @@ -658,7 +658,7 @@ int rad_expand_xlat(request_t *request, char const *cmd, */ sublen = 0; } else { - fr_strerror_printf("Failed expanding substring"); + fr_strerror_const("Failed expanding substring"); return -1; } } @@ -670,7 +670,7 @@ int rad_expand_xlat(request_t *request, char const *cmd, left--; if (left <= 0) { - fr_strerror_printf("Ran out of space while expanding arguments"); + fr_strerror_const("Ran out of space while expanding arguments"); return -1; } } diff --git a/src/lib/server/virtual_servers.c b/src/lib/server/virtual_servers.c index 0d23ca27f47..484721367e7 100644 --- a/src/lib/server/virtual_servers.c +++ b/src/lib/server/virtual_servers.c @@ -1533,7 +1533,7 @@ int virtual_server_section_register(virtual_server_compile_t const *entry) #endif if (!rbtree_insert(server_section_name_tree, entry)) { - fr_strerror_printf("Failed inserting entry into internal tree"); + fr_strerror_const("Failed inserting entry into internal tree"); return -1; } diff --git a/src/lib/sim/milenage.c b/src/lib/sim/milenage.c index 9bebbce1251..a2d15015754 100644 --- a/src/lib/sim/milenage.c +++ b/src/lib/sim/milenage.c @@ -465,7 +465,7 @@ int milenage_check(uint8_t ik[MILENAGE_IK_SIZE], if (CRYPTO_memcmp(mac_a, autn + 8, 8) != 0) { FR_PROTO_HEX_DUMP(autn + 8, 8, "Received MAC_A"); - fr_strerror_printf("MAC mismatch"); + fr_strerror_const("MAC mismatch"); return -1; } diff --git a/src/lib/unlang/xlat_eval.c b/src/lib/unlang/xlat_eval.c index 149ed0ac0bb..8b0e9bddfb7 100644 --- a/src/lib/unlang/xlat_eval.c +++ b/src/lib/unlang/xlat_eval.c @@ -593,7 +593,7 @@ static xlat_action_t xlat_eval_pair_real(TALLOC_CTX *ctx, fr_cursor_t *out, requ value = fr_value_box_alloc(ctx, FR_TYPE_UINT32, NULL, false); if (!value) { oom: - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); ret = XLAT_ACTION_FAIL; goto done; } diff --git a/src/lib/unlang/xlat_tokenize.c b/src/lib/unlang/xlat_tokenize.c index 1d9aedf8e9a..1a56805b34d 100644 --- a/src/lib/unlang/xlat_tokenize.c +++ b/src/lib/unlang/xlat_tokenize.c @@ -232,7 +232,7 @@ static inline int xlat_tokenize_alternation(TALLOC_CTX *ctx, xlat_exp_t **head, } if (!fr_sbuff_adv_past_str_literal(in, ":-")) { - fr_strerror_printf("Expected ':-' after first expansion"); + fr_strerror_const("Expected ':-' after first expansion"); goto error; } @@ -254,12 +254,12 @@ static inline int xlat_tokenize_alternation(TALLOC_CTX *ctx, xlat_exp_t **head, if (!node->alternate) { talloc_free(node); - fr_strerror_printf("Empty expansion is invalid"); + fr_strerror_const("Empty expansion is invalid"); goto error; } if (!fr_sbuff_next_if_char(in, '}')) { - fr_strerror_printf("Missing closing brace"); + fr_strerror_const("Missing closing brace"); goto error; } @@ -302,7 +302,7 @@ static inline int xlat_tokenize_regex(TALLOC_CTX *ctx, xlat_exp_t **head, xlat_f if (!fr_sbuff_is_char(in, '}')) { if (!fr_sbuff_remaining(in)) { - fr_strerror_printf("Missing closing brace"); + fr_strerror_const("Missing closing brace"); fr_sbuff_marker_release(&m_s); return -1; } @@ -360,7 +360,7 @@ static inline int xlat_tokenize_function_single_arg(TALLOC_CTX *ctx, xlat_exp_t fr_sbuff_adv_past_allowed(in, SIZE_MAX, func_chars); if (!fr_sbuff_is_char(in, ':')) { - fr_strerror_printf("Can't find function/argument separator"); + fr_strerror_const("Can't find function/argument separator"); bad_function: *head = NULL; fr_sbuff_set(in, &m_s); /* backtrack */ @@ -376,7 +376,7 @@ static inline int xlat_tokenize_function_single_arg(TALLOC_CTX *ctx, xlat_exp_t node = xlat_exp_alloc(ctx, XLAT_FUNC, fr_sbuff_current(&m_s), fr_sbuff_behind(&m_s)); if (!func) { if (!rules || !rules->allow_unresolved) { - fr_strerror_printf("Unresolved expansion functions are not allowed here"); + fr_strerror_const("Unresolved expansion functions are not allowed here"); goto bad_function; } xlat_exp_set_type(node, XLAT_FUNC_UNRESOLVED); @@ -404,7 +404,7 @@ static inline int xlat_tokenize_function_single_arg(TALLOC_CTX *ctx, xlat_exp_t } if (!fr_sbuff_next_if_char(in, '}')) { - fr_strerror_printf("Missing closing brace"); + fr_strerror_const("Missing closing brace"); goto error; } @@ -449,7 +449,7 @@ static inline int xlat_tokenize_function_multi_arg(TALLOC_CTX *ctx, xlat_exp_t * fr_sbuff_adv_past_allowed(in, SIZE_MAX, func_chars); if (!fr_sbuff_is_char(in, ':')) { - fr_strerror_printf("Can't find function/argument separator"); + fr_strerror_const("Can't find function/argument separator"); bad_function: *head = NULL; fr_sbuff_set(in, &m_s); /* backtrack */ @@ -465,7 +465,7 @@ static inline int xlat_tokenize_function_multi_arg(TALLOC_CTX *ctx, xlat_exp_t * node = xlat_exp_alloc(ctx, XLAT_FUNC, fr_sbuff_current(&m_s), fr_sbuff_behind(&m_s)); if (!func) { if (!rules || !rules->allow_unresolved) { - fr_strerror_printf("Unresolved expansion functions are not allowed here"); + fr_strerror_const("Unresolved expansion functions are not allowed here"); goto bad_function; } xlat_exp_set_type(node, XLAT_FUNC_UNRESOLVED); @@ -493,7 +493,7 @@ static inline int xlat_tokenize_function_multi_arg(TALLOC_CTX *ctx, xlat_exp_t * } if (!fr_sbuff_next_if_char(in, ')')) { - fr_strerror_printf("Missing closing brace"); + fr_strerror_const("Missing closing brace"); goto error; } @@ -585,7 +585,7 @@ static inline int xlat_tokenize_attribute(TALLOC_CTX *ctx, xlat_exp_t **head, xl node->flags.needs_async = func->needs_async; if (!fr_sbuff_next_if_char(in, '}')) { - fr_strerror_printf("Missing closing brace"); + fr_strerror_const("Missing closing brace"); goto error; } @@ -612,7 +612,7 @@ static inline int xlat_tokenize_attribute(TALLOC_CTX *ctx, xlat_exp_t **head, xl if (!t_rules || !t_rules->allow_unresolved) { talloc_free(vpt); - fr_strerror_printf("Unresolved attributes not allowed in expansions here"); + fr_strerror_const("Unresolved attributes not allowed in expansions here"); fr_sbuff_set(in, &m_s); /* Error at the start of the attribute */ goto error; } @@ -637,7 +637,7 @@ static inline int xlat_tokenize_attribute(TALLOC_CTX *ctx, xlat_exp_t **head, xl } if (!fr_sbuff_next_if_char(in, '}')) { - fr_strerror_printf("Missing closing brace"); + fr_strerror_const("Missing closing brace"); goto error; } @@ -680,7 +680,7 @@ static int xlat_tokenize_expansion(TALLOC_CTX *ctx, xlat_exp_t **head, xlat_flag * :-bar} */ if (fr_sbuff_is_str_literal(in, ":-")) { - fr_strerror_printf("First item in alternation cannot be empty"); + fr_strerror_const("First item in alternation cannot be empty"); return -2; } @@ -714,7 +714,7 @@ static int xlat_tokenize_expansion(TALLOC_CTX *ctx, xlat_exp_t **head, xlat_flag * e.g. '%{myfirstxlat' */ if (!fr_sbuff_remaining(in)) { - fr_strerror_printf("Missing closing brace"); + fr_strerror_const("Missing closing brace"); fr_sbuff_marker_release(&s_m); return -1; } @@ -725,15 +725,15 @@ static int xlat_tokenize_expansion(TALLOC_CTX *ctx, xlat_exp_t **head, xlat_flag if (len == 0) { switch (hint) { case '}': - fr_strerror_printf("Empty expression is invalid"); + fr_strerror_const("Empty expression is invalid"); return -1; case ':': - fr_strerror_printf("Missing expansion function"); + fr_strerror_const("Missing expansion function"); return -1; case '[': - fr_strerror_printf("Missing attribute name"); + fr_strerror_const("Missing attribute name"); return -1; default: @@ -942,7 +942,7 @@ static int xlat_tokenize_literal(TALLOC_CTX *ctx, xlat_exp_t **head, xlat_flags_ if (len == 0) TALLOC_FREE(node); /* Free the empty node */ if (!fr_sbuff_is_char(in, '}')) { - fr_strerror_printf("Missing closing brace"); + fr_strerror_const("Missing closing brace"); goto error; } /* @@ -1232,7 +1232,7 @@ ssize_t xlat_tokenize_ephemeral(TALLOC_CTX *ctx, xlat_exp_t **head, xlat_flags_t * Create ephemeral instance data for the xlat */ if (xlat_instantiate_ephemeral(*head) < 0) { - fr_strerror_printf("Failed performing ephemeral instantiation for xlat"); + fr_strerror_const("Failed performing ephemeral instantiation for xlat"); TALLOC_FREE(*head); return 0; } @@ -1363,7 +1363,7 @@ ssize_t xlat_tokenize_argv(TALLOC_CTX *ctx, xlat_exp_t **head, xlat_flags_t *fla * `back quoted strings aren't supported` */ case T_BACK_QUOTED_STRING: - fr_strerror_printf("Unexpected `...` string"); + fr_strerror_const("Unexpected `...` string"); goto error; default: @@ -1372,7 +1372,7 @@ ssize_t xlat_tokenize_argv(TALLOC_CTX *ctx, xlat_exp_t **head, xlat_flags_t *fla } if ((quote != T_BARE_WORD) && !fr_sbuff_next_if_char(&our_in, fr_token_quote[quote])) { /* Quoting */ - fr_strerror_printf("Unterminated string"); + fr_strerror_const("Unterminated string"); fr_sbuff_set(&our_in, &m); goto error; } @@ -1403,7 +1403,7 @@ ssize_t xlat_tokenize_argv(TALLOC_CTX *ctx, xlat_exp_t **head, xlat_flags_t *fla * arguments were smushed together. */ if (fr_sbuff_extend(&our_in) && (len == 0)) { - fr_strerror_printf("Unexpected text after argument"); + fr_strerror_const("Unexpected text after argument"); goto error; } } diff --git a/src/lib/util/base64.c b/src/lib/util/base64.c index c218b02811b..09e64691056 100644 --- a/src/lib/util/base64.c +++ b/src/lib/util/base64.c @@ -310,7 +310,7 @@ ssize_t fr_base64_decode(uint8_t *out, size_t outlen, char const *in, size_t inl break; default: - fr_strerror_printf("Invalid base64 padding data"); + fr_strerror_const("Invalid base64 padding data"); return p - end; } diff --git a/src/lib/util/cap.c b/src/lib/util/cap.c index 6965251be5d..6a4973a8d3a 100644 --- a/src/lib/util/cap.c +++ b/src/lib/util/cap.c @@ -119,7 +119,7 @@ int fr_cap_enable(cap_value_t cap, cap_flag_t set) pthread_mutex_lock(&cap_mutex); if (set == CAP_PERMITTED) { - fr_strerror_printf("Can't modify permitted capabilities"); + fr_strerror_const("Can't modify permitted capabilities"); goto done; } diff --git a/src/lib/util/debug.c b/src/lib/util/debug.c index a5ba396c722..553f37fb551 100644 --- a/src/lib/util/debug.c +++ b/src/lib/util/debug.c @@ -257,7 +257,7 @@ int fr_get_lsan_state(void) #else int fr_get_lsan_state(void) { - fr_strerror_printf("Not built with support for LSAN interface"); + fr_strerror_const("Not built with support for LSAN interface"); return -2; } #endif @@ -431,7 +431,7 @@ static int fr_get_debug_state(void) #else static int fr_get_debug_state(void) { - fr_strerror_printf("PTRACE not available"); + fr_strerror_const("PTRACE not available"); return DEBUGGER_STATE_UNKNOWN_NO_PTRACE; } @@ -671,7 +671,7 @@ static int fr_set_pr_dumpable_flag(bool dumpable) #else static int fr_set_pr_dumpable_flag(UNUSED bool dumpable) { - fr_strerror_printf("Changing value of PR_DUMPABLE not supported on this system"); + fr_strerror_const("Changing value of PR_DUMPABLE not supported on this system"); return -2; } #endif @@ -717,7 +717,7 @@ static int fr_get_pr_dumpable_flag(void) #else static int fr_get_pr_dumpable_flag(void) { - fr_strerror_printf("Getting value of PR_DUMPABLE not supported on this system"); + fr_strerror_const("Getting value of PR_DUMPABLE not supported on this system"); return -2; } #endif @@ -839,7 +839,7 @@ static int fr_fault_check_permissions(void) */ len = snprintf(filename, sizeof(filename), "%.*s", (int)(q - panic_action), panic_action); if (is_truncated(len, sizeof(filename))) { - fr_strerror_printf("Failed writing panic_action to temporary buffer (truncated)"); + fr_strerror_const("Failed writing panic_action to temporary buffer (truncated)"); return -1; } p = filename; @@ -1167,7 +1167,7 @@ int fr_fault_setup(TALLOC_CTX *ctx, char const *cmd, char const *program) out += ret = snprintf(out, left, "%.*s%s", (int) (q - p), p, program ? program : ""); if (left <= ret) { oob: - fr_strerror_printf("Panic action too long"); + fr_strerror_const("Panic action too long"); return -1; } left -= ret; diff --git a/src/lib/util/dict_fixup.c b/src/lib/util/dict_fixup.c index 09a2fc4a1af..55045555372 100644 --- a/src/lib/util/dict_fixup.c +++ b/src/lib/util/dict_fixup.c @@ -96,7 +96,7 @@ static inline CC_HINT(always_inline) int dict_fixup_common(char const *filename, { common->filename = talloc_strdup(common, filename); if (!common->filename) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } common->line = line; @@ -134,7 +134,7 @@ int dict_fixup_enumv(dict_fixup_ctx_t *fctx, char const *filename, int line, fixup = talloc(fctx->pool, dict_fixup_enumv_t); if (!fixup) { oom: - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } *fixup = (dict_fixup_enumv_t) { @@ -211,7 +211,7 @@ int dict_fixup_group(dict_fixup_ctx_t *fctx, char const *filename, int line, fixup = talloc(fctx->pool, dict_fixup_group_t); if (!fixup) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } *fixup = (dict_fixup_group_t) { @@ -378,7 +378,7 @@ int dict_fixup_clone(dict_fixup_ctx_t *fctx, char const *filename, int line, fixup = talloc(fctx->pool, dict_fixup_clone_t); if (!fixup) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } *fixup = (dict_fixup_clone_t) { diff --git a/src/lib/util/dict_priv.h b/src/lib/util/dict_priv.h index 7a755e1b9f6..1e132e022f1 100644 --- a/src/lib/util/dict_priv.h +++ b/src/lib/util/dict_priv.h @@ -46,7 +46,7 @@ extern "C" { if (!(_dict)) { \ _dict = dict_gctx ? dict_gctx->internal : NULL; \ if (unlikely(!(_dict))) { \ - fr_strerror_printf("No dictionaries available for attribute resolution"); \ + fr_strerror_const("No dictionaries available for attribute resolution"); \ return (_ret); \ } \ } \ diff --git a/src/lib/util/dict_tokenize.c b/src/lib/util/dict_tokenize.c index 651c2ac2f32..ecdea2047d4 100644 --- a/src/lib/util/dict_tokenize.c +++ b/src/lib/util/dict_tokenize.c @@ -161,7 +161,7 @@ static int dict_root_set(fr_dict_t *dict, char const *name, unsigned int proto_n }; if (!fr_cond_assert(!dict->root)) { - fr_strerror_printf("Dictionary root already set"); + fr_strerror_const("Dictionary root already set"); return -1; } @@ -222,7 +222,7 @@ static int dict_process_type_field(dict_tokenize_ctx_t *ctx, char const *name, f } else if (strcmp(name, "bit") == 0) { if (ctx->stack[ctx->stack_depth].da->type != FR_TYPE_STRUCT) { - fr_strerror_printf("Bit fields can only be used inside of a STRUCT"); + fr_strerror_const("Bit fields can only be used inside of a STRUCT"); return -1; } @@ -240,7 +240,7 @@ static int dict_process_type_field(dict_tokenize_ctx_t *ctx, char const *name, f } else if (length < 56) { /* for laziness in encode / decode */ type = FR_TYPE_UINT64; } else { - fr_strerror_printf("Invalid length for bit field"); + fr_strerror_const("Invalid length for bit field"); return -1; } @@ -250,7 +250,7 @@ static int dict_process_type_field(dict_tokenize_ctx_t *ctx, char const *name, f flags->type_size = length; } else { - fr_strerror_printf("Only 'octets' types can have a 'length' parameter"); + fr_strerror_const("Only 'octets' types can have a 'length' parameter"); return -1; } @@ -348,12 +348,12 @@ static int dict_process_flag_field(dict_tokenize_ctx_t *ctx, char *name, fr_type } else if (strcmp(key, "key") == 0) { if ((type != FR_TYPE_UINT8) && (type != FR_TYPE_UINT16) && (type != FR_TYPE_UINT32)) { - fr_strerror_printf("The 'key' flag can only be used for attributes of type 'uint8', 'uint16', or 'uint32'"); + fr_strerror_const("The 'key' flag can only be used for attributes of type 'uint8', 'uint16', or 'uint32'"); return -1; } if (flags->extra) { - fr_strerror_printf("Bit fields cannot be key fields"); + fr_strerror_const("Bit fields cannot be key fields"); return -1; } @@ -362,7 +362,7 @@ static int dict_process_flag_field(dict_tokenize_ctx_t *ctx, char *name, fr_type } else if (strcmp(key, "length") == 0) { if (!value || (strcmp(value, "uint16") != 0)) { - fr_strerror_printf("The 'length' flag can only be used with value 'uint16'"); + fr_strerror_const("The 'length' flag can only be used with value 'uint16'"); } flags->extra = 1; @@ -427,12 +427,12 @@ static int dict_process_flag_field(dict_tokenize_ctx_t *ctx, char *name, fr_type } else if (strcmp(key, "ref") == 0) { if (!value) { - fr_strerror_printf("Missing attribute name for 'ref=...'"); + fr_strerror_const("Missing attribute name for 'ref=...'"); return -1; } if (flags->extra) { - fr_strerror_printf("Cannot use 'ref' with other flags"); + fr_strerror_const("Cannot use 'ref' with other flags"); return -1; } @@ -448,7 +448,7 @@ static int dict_process_flag_field(dict_tokenize_ctx_t *ctx, char *name, fr_type } else if (strcmp(key, "clone") == 0) { if (!value) { - fr_strerror_printf("Missing attribute name for 'clone=...'"); + fr_strerror_const("Missing attribute name for 'clone=...'"); return -1; } @@ -501,7 +501,7 @@ static int dict_process_flag_field(dict_tokenize_ctx_t *ctx, char *name, fr_type static int dict_gctx_push(dict_tokenize_ctx_t *ctx, fr_dict_attr_t const *da) { if ((ctx->stack_depth + 1) >= MAX_STACK) { - fr_strerror_printf_push("Attribute definitions are nested too deep."); + fr_strerror_const_push("Attribute definitions are nested too deep."); return -1; } @@ -537,7 +537,7 @@ static int dict_read_process_alias(dict_tokenize_ctx_t *ctx, char **argv, int ar fr_hash_table_t *namespace; if (argc != 2) { - fr_strerror_printf("Invalid ALIAS syntax"); + fr_strerror_const("Invalid ALIAS syntax"); return -1; } @@ -545,7 +545,7 @@ static int dict_read_process_alias(dict_tokenize_ctx_t *ctx, char **argv, int ar * Dictionaries need to have real names, not shitty ones. */ if (strncmp(argv[0], "Attr-", 5) == 0) { - fr_strerror_printf("Invalid ALIAS name"); + fr_strerror_const("Invalid ALIAS name"); return -1; } @@ -584,7 +584,7 @@ static int dict_read_process_alias(dict_tokenize_ctx_t *ctx, char **argv, int ar } if (!fr_hash_table_insert(namespace, new)) { - fr_strerror_printf("Internal error storing attribute"); + fr_strerror_const("Internal error storing attribute"); goto error; } @@ -608,7 +608,7 @@ static int dict_read_process_attribute(dict_tokenize_ctx_t *ctx, char **argv, in char *ref = NULL; if ((argc < 3) || (argc > 4)) { - fr_strerror_printf("Invalid ATTRIBUTE syntax"); + fr_strerror_const("Invalid ATTRIBUTE syntax"); return -1; } @@ -616,7 +616,7 @@ static int dict_read_process_attribute(dict_tokenize_ctx_t *ctx, char **argv, in * Dictionaries need to have real names, not shitty ones. */ if (strncmp(argv[0], "Attr-", 5) == 0) { - fr_strerror_printf("Invalid ATTRIBUTE name"); + fr_strerror_const("Invalid ATTRIBUTE name"); return -1; } @@ -625,7 +625,7 @@ static int dict_read_process_attribute(dict_tokenize_ctx_t *ctx, char **argv, in if (dict_process_type_field(ctx, argv[2], &type, &flags) < 0) return -1; if (flags.extra && (flags.subtype == FLAG_BIT_FIELD)) { - fr_strerror_printf("Bit fields can only be defined as a MEMBER of a STRUCT"); + fr_strerror_const("Bit fields can only be defined as a MEMBER of a STRUCT"); return -1; } @@ -648,7 +648,7 @@ static int dict_read_process_attribute(dict_tokenize_ctx_t *ctx, char **argv, in */ if (strchr(argv[1], '.') == 0) { if (!dict_read_sscanf_i(&attr, argv[1])) { - fr_strerror_printf("Invalid ATTRIBUTE number"); + fr_strerror_const("Invalid ATTRIBUTE number"); return -1; } @@ -659,7 +659,7 @@ static int dict_read_process_attribute(dict_tokenize_ctx_t *ctx, char **argv, in } else { if (!ctx->relative_attr) { - fr_strerror_printf("Unknown parent for partial OID"); + fr_strerror_const("Unknown parent for partial OID"); return -1; } @@ -817,7 +817,7 @@ static int dict_read_process_attribute(dict_tokenize_ctx_t *ctx, char **argv, in check: if (fr_dict_attr_ref(da)) { - fr_strerror_printf("References MUST NOT refer to an ATTRIBUTE which also has 'ref=...'"); + fr_strerror_const("References MUST NOT refer to an ATTRIBUTE which also has 'ref=...'"); talloc_free(ref); return -1; } @@ -866,12 +866,12 @@ static int dict_read_process_member(dict_tokenize_ctx_t *ctx, char **argv, int a char *ref = NULL; if ((argc < 2) || (argc > 3)) { - fr_strerror_printf("Invalid MEMBER syntax"); + fr_strerror_const("Invalid MEMBER syntax"); return -1; } if (ctx->stack[ctx->stack_depth].da->type != FR_TYPE_STRUCT) { - fr_strerror_printf("MEMBER can only be used for ATTRIBUTEs of type 'struct'"); + fr_strerror_const("MEMBER can only be used for ATTRIBUTEs of type 'struct'"); return -1; } @@ -879,7 +879,7 @@ static int dict_read_process_member(dict_tokenize_ctx_t *ctx, char **argv, int a * Dictionaries need to have real names, not shitty ones. */ if (strncmp(argv[0], "Attr-", 5) == 0) { - fr_strerror_printf("Invalid MEMBER name"); + fr_strerror_const("Invalid MEMBER name"); return -1; } @@ -894,7 +894,7 @@ static int dict_read_process_member(dict_tokenize_ctx_t *ctx, char **argv, int a if (dict_process_flag_field(ctx, argv[2], type, &flags, &ref) < 0) return -1; if (ref && (type != FR_TYPE_TLV) && !(flags.extra && (flags.subtype == FLAG_KEY_FIELD))) { - fr_strerror_printf("Only MEMBERs of type 'tlv' or with 'key' flags can have references");\ + fr_strerror_const("Only MEMBERs of type 'tlv' or with 'key' flags can have references");\ return -1; } @@ -915,7 +915,7 @@ static int dict_read_process_member(dict_tokenize_ctx_t *ctx, char **argv, int a previous = dict_attr_child_by_num(ctx->stack[ctx->stack_depth].da, ctx->stack[ctx->stack_depth].member_num); if (!previous) { - fr_strerror_printf("Failed to find previous MEMBER"); + fr_strerror_const("Failed to find previous MEMBER"); return -1; } @@ -1048,7 +1048,7 @@ static int dict_read_process_value(dict_tokenize_ctx_t *ctx, char **argv, int ar fr_dict_attr_t const *parent = ctx->stack[ctx->stack_depth].da; if (argc != 3) { - fr_strerror_printf("Invalid VALUE syntax"); + fr_strerror_const("Invalid VALUE syntax"); return -1; } @@ -1087,7 +1087,7 @@ static int dict_read_process_value(dict_tokenize_ctx_t *ctx, char **argv, int ar argv[0], strlen(argv[0]), argv[1], strlen(argv[1]), argv[2], strlen(argv[2]), parent) < 0) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } return 0; @@ -1149,7 +1149,7 @@ static int dict_read_process_flags(UNUSED fr_dict_t *dict, char **argv, int argc } } - fr_strerror_printf("Invalid FLAGS syntax"); + fr_strerror_const("Invalid FLAGS syntax"); return -1; } @@ -1173,7 +1173,7 @@ static int dict_read_process_struct(dict_tokenize_ctx_t *ctx, char **argv, int a char *name = argv[0]; if (argc != 3) { - fr_strerror_printf("Invalid STRUCT syntax"); + fr_strerror_const("Invalid STRUCT syntax"); return -1; } @@ -1327,7 +1327,7 @@ static int dict_read_parse_format(char const *format, unsigned int *pvalue, int if ((*pvalue != VENDORPEC_WIMAX) || (type != 1) || (length != 1)) { - fr_strerror_printf("Only WiMAX VSAs can have continuations"); + fr_strerror_const("Only WiMAX VSAs can have continuations"); return -1; } } @@ -1351,7 +1351,7 @@ static int dict_read_process_protocol(char **argv, int argc) bool require_dl = false; if ((argc < 2) || (argc > 3)) { - fr_strerror_printf("Missing arguments after PROTOCOL. Expected PROTOCOL "); + fr_strerror_const("Missing arguments after PROTOCOL. Expected PROTOCOL "); return -1; } @@ -1487,7 +1487,7 @@ static int dict_read_process_vendor(fr_dict_t *dict, char **argv, int argc) fr_dict_vendor_t *mutable; if ((argc < 2) || (argc > 3)) { - fr_strerror_printf("Invalid VENDOR syntax"); + fr_strerror_const("Invalid VENDOR syntax"); return -1; } @@ -1495,7 +1495,7 @@ static int dict_read_process_vendor(fr_dict_t *dict, char **argv, int argc) * Validate all entries */ if (!dict_read_sscanf_i(&value, argv[1])) { - fr_strerror_printf("Invalid number in VENDOR"); + fr_strerror_const("Invalid number in VENDOR"); return -1; } @@ -1514,7 +1514,7 @@ static int dict_read_process_vendor(fr_dict_t *dict, char **argv, int argc) dv = fr_dict_vendor_by_num(dict, value); if (!dv) { - fr_strerror_printf("Failed adding format for VENDOR"); + fr_strerror_const("Failed adding format for VENDOR"); return -1; } @@ -1689,7 +1689,7 @@ static int _dict_from_file(dict_tokenize_ctx_t *ctx, if (argc == 0) continue; if (argc == 1) { - fr_strerror_printf("Invalid entry"); + fr_strerror_const("Invalid entry"); error: fr_strerror_printf_push("Failed parsing dictionary at %s[%d]", fr_cwd_strip(fn), line); @@ -1880,7 +1880,7 @@ static int _dict_from_file(dict_tokenize_ctx_t *ctx, */ if (strcasecmp(argv[0], "PROTOCOL") == 0) { if (argc < 2) { - fr_strerror_printf_push("Invalid PROTOCOL entry"); + fr_strerror_const_push("Invalid PROTOCOL entry"); goto error; } if (dict_read_process_protocol(argv + 1, argc - 1) == -1) goto error; @@ -1894,7 +1894,7 @@ static int _dict_from_file(dict_tokenize_ctx_t *ctx, fr_dict_t *found; if (argc != 2) { - fr_strerror_printf_push("Invalid BEGIN-PROTOCOL entry"); + fr_strerror_const_push("Invalid BEGIN-PROTOCOL entry"); goto error; } @@ -1904,7 +1904,7 @@ static int _dict_from_file(dict_tokenize_ctx_t *ctx, * statements. */ if (ctx->dict != dict_gctx->internal) { - fr_strerror_printf_push("Nested BEGIN-PROTOCOL statements are not allowed"); + fr_strerror_const_push("Nested BEGIN-PROTOCOL statements are not allowed"); goto error; } @@ -1941,7 +1941,7 @@ static int _dict_from_file(dict_tokenize_ctx_t *ctx, fr_dict_t const *found; if (argc != 2) { - fr_strerror_printf("Invalid END-PROTOCOL entry"); + fr_strerror_const("Invalid END-PROTOCOL entry"); goto error; } @@ -2006,13 +2006,13 @@ static int _dict_from_file(dict_tokenize_ctx_t *ctx, fr_dict_attr_t const *common; if (argc != 2) { - fr_strerror_printf_push("Invalid BEGIN-TLV entry"); + fr_strerror_const_push("Invalid BEGIN-TLV entry"); goto error; } da = fr_dict_attr_by_oid(NULL, ctx->stack[ctx->stack_depth].da, argv[1]); if (!da) { - fr_strerror_printf_push("Failed resolving attribute in BEGIN-TLV entry"); + fr_strerror_const_push("Failed resolving attribute in BEGIN-TLV entry"); goto error; } @@ -2041,7 +2041,7 @@ static int _dict_from_file(dict_tokenize_ctx_t *ctx, */ if (strcasecmp(argv[0], "END-TLV") == 0) { if (argc != 2) { - fr_strerror_printf_push("Invalid END-TLV entry"); + fr_strerror_const_push("Invalid END-TLV entry"); goto error; } @@ -2049,7 +2049,7 @@ static int _dict_from_file(dict_tokenize_ctx_t *ctx, da = fr_dict_attr_by_oid(NULL, ctx->stack[ctx->stack_depth - 1].da, argv[1]); if (!da) { - fr_strerror_printf_push("Failed resolving attribute in END-TLV entry"); + fr_strerror_const_push("Failed resolving attribute in END-TLV entry"); goto error; } @@ -2091,7 +2091,7 @@ static int _dict_from_file(dict_tokenize_ctx_t *ctx, fr_dict_attr_t *mutable; if (argc < 2) { - fr_strerror_printf_push("Invalid BEGIN-VENDOR entry"); + fr_strerror_const_push("Invalid BEGIN-VENDOR entry"); goto error; } @@ -2201,7 +2201,7 @@ static int _dict_from_file(dict_tokenize_ctx_t *ctx, fr_dict_vendor_t const *vendor; if (argc != 2) { - fr_strerror_printf_push("Invalid END-VENDOR entry"); + fr_strerror_const_push("Invalid END-VENDOR entry"); goto error; } @@ -2311,7 +2311,7 @@ int fr_dict_internal_afrom_file(fr_dict_t **out, char const *dict_subdir) char *type_name; if (unlikely(!dict_gctx)) { - fr_strerror_printf("fr_dict_global_ctx_init() must be called before loading dictionary files"); + fr_strerror_const("fr_dict_global_ctx_init() must be called before loading dictionary files"); return -1; } @@ -2408,12 +2408,12 @@ int fr_dict_protocol_afrom_file(fr_dict_t **out, char const *proto_name, char co *out = NULL; if (unlikely(!dict_gctx)) { - fr_strerror_printf("fr_dict_global_ctx_init() must be called before loading dictionary files"); + fr_strerror_const("fr_dict_global_ctx_init() must be called before loading dictionary files"); return -1; } if (unlikely(!dict_gctx->internal)) { - fr_strerror_printf("Internal dictionary must be initialised before loading protocol dictionaries"); + fr_strerror_const("Internal dictionary must be initialised before loading protocol dictionaries"); return -1; } diff --git a/src/lib/util/dict_unknown.c b/src/lib/util/dict_unknown.c index 711e1a6fd43..61407781869 100644 --- a/src/lib/util/dict_unknown.c +++ b/src/lib/util/dict_unknown.c @@ -267,7 +267,7 @@ fr_dict_attr_t *fr_dict_unknown_vendor_afrom_num(TALLOC_CTX *ctx, case FR_TYPE_VENDOR: if (!fr_cond_assert(!parent->flags.is_unknown)) return NULL; - fr_strerror_printf("Unknown vendor cannot be parented by another vendor"); + fr_strerror_const("Unknown vendor cannot be parented by another vendor"); return NULL; default: diff --git a/src/lib/util/dict_util.c b/src/lib/util/dict_util.c index 9f9d589889c..8b2d5aca481 100644 --- a/src/lib/util/dict_util.c +++ b/src/lib/util/dict_util.c @@ -836,7 +836,7 @@ int dict_vendor_add(fr_dict_t *dict, char const *name, unsigned int num) vendor = talloc_zero(dict, fr_dict_vendor_t); if (!vendor) { oom: - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } @@ -976,7 +976,7 @@ int dict_attr_child_add(fr_dict_attr_t *parent, fr_dict_attr_t *child) if (!children) { children = talloc_zero_array(parent, fr_dict_attr_t const *, UINT8_MAX + 1); if (!children) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } if (dict_attr_children_set(parent, children) < 0) return -1; @@ -1102,7 +1102,7 @@ int dict_attr_add_to_namespace(fr_dict_t *dict, fr_dict_attr_t const *parent, fr * updated to point to the new definition. */ if (!fr_hash_table_replace(namespace, da)) { - fr_strerror_printf("Internal error storing attribute"); + fr_strerror_const("Internal error storing attribute"); goto error; } } @@ -1131,12 +1131,12 @@ int dict_attr_add_to_namespace(fr_dict_t *dict, fr_dict_attr_t const *parent, fr v6->type = FR_TYPE_IPV6_ADDR; if (!fr_hash_table_replace(dict->attributes_combo, v4)) { - fr_strerror_printf("Failed inserting IPv4 version of combo attribute"); + fr_strerror_const("Failed inserting IPv4 version of combo attribute"); goto error; } if (!fr_hash_table_replace(dict->attributes_combo, v6)) { - fr_strerror_printf("Failed inserting IPv6 version of combo attribute"); + fr_strerror_const("Failed inserting IPv6 version of combo attribute"); goto error; } break; @@ -1157,12 +1157,12 @@ int dict_attr_add_to_namespace(fr_dict_t *dict, fr_dict_attr_t const *parent, fr v6->type = FR_TYPE_IPV6_PREFIX; if (!fr_hash_table_replace(dict->attributes_combo, v4)) { - fr_strerror_printf("Failed inserting IPv4 version of combo attribute"); + fr_strerror_const("Failed inserting IPv4 version of combo attribute"); goto error; } if (!fr_hash_table_replace(dict->attributes_combo, v6)) { - fr_strerror_printf("Failed inserting IPv6 version of combo attribute"); + fr_strerror_const("Failed inserting IPv6 version of combo attribute"); goto error; } break; @@ -1306,7 +1306,7 @@ int dict_attr_enum_add_name(fr_dict_attr_t *da, char const *name, * If the parent isn't a key field, then we CANNOT add a child struct. */ if (!fr_dict_attr_is_key_field(da) && child_struct) { - fr_strerror_printf("Child structures cannot be defined for VALUEs which are not for 'key' attributes"); + fr_strerror_const("Child structures cannot be defined for VALUEs which are not for 'key' attributes"); return -1; } @@ -1536,7 +1536,7 @@ int fr_dict_attr_enum_add_name_next(fr_dict_attr_t *da, char const *name) fr_value_box_increment(&v); if (fr_value_box_cmp_op(T_OP_CMP_EQ, &v, &s) == 0) { - fr_strerror_printf("No free integer values for enumeration"); + fr_strerror_const("No free integer values for enumeration"); return -1; } @@ -1620,7 +1620,7 @@ int fr_dict_oid_component_legacy(unsigned int *out, char const **oid) return 0; default: - fr_strerror_printf("Unexpected text after OID component"); + fr_strerror_const("Unexpected text after OID component"); *out = 0; return -1; } @@ -1686,7 +1686,7 @@ ssize_t fr_dict_attr_by_oid_legacy(fr_dict_t const *dict, fr_dict_attr_t const * */ if (((*parent)->type != FR_TYPE_VENDOR) && ((*parent)->type != FR_TYPE_VSA) && !(*parent)->flags.is_root && (num > UINT8_MAX)) { - fr_strerror_printf("TLV attributes must be between 0..255 inclusive"); + fr_strerror_const("TLV attributes must be between 0..255 inclusive"); return 0; } @@ -1954,12 +1954,12 @@ ssize_t dict_by_protocol_substr(fr_dict_attr_err_t *err, &our_name, SIZE_MAX, fr_dict_attr_allowed_chars); if (len == 0) { - fr_strerror_printf("Zero length attribute name"); + fr_strerror_const("Zero length attribute name"); if (err) *err = FR_DICT_ATTR_PARSE_ERROR; return 0; } if (len > FR_DICT_ATTR_MAX_NAME_LEN) { - fr_strerror_printf("Attribute name too long"); + fr_strerror_const("Attribute name too long"); if (err) *err = FR_DICT_ATTR_PARSE_ERROR; return -(FR_DICT_ATTR_MAX_NAME_LEN); } @@ -2547,12 +2547,12 @@ ssize_t fr_dict_attr_by_name_substr(fr_dict_attr_err_t *err, fr_dict_attr_t cons &our_name, SIZE_MAX, fr_dict_attr_allowed_chars); if (len == 0) { - fr_strerror_printf("Zero length attribute name"); + fr_strerror_const("Zero length attribute name"); if (err) *err = FR_DICT_ATTR_PARSE_ERROR; return 0; } if (len > FR_DICT_ATTR_MAX_NAME_LEN) { - fr_strerror_printf("Attribute name too long"); + fr_strerror_const("Attribute name too long"); if (err) *err = FR_DICT_ATTR_PARSE_ERROR; return -(FR_DICT_ATTR_MAX_NAME_LEN); } @@ -2907,13 +2907,13 @@ fr_dict_t *dict_alloc(TALLOC_CTX *ctx) fr_dict_t *dict; if (!dict_gctx) { - fr_strerror_printf("Initialise global dictionary ctx with fr_dict_global_ctx_init()"); + fr_strerror_const("Initialise global dictionary ctx with fr_dict_global_ctx_init()"); return NULL; } dict = talloc_zero(ctx, fr_dict_t); if (!dict) { - fr_strerror_printf("Failed allocating memory for dictionary"); + fr_strerror_const("Failed allocating memory for dictionary"); error: talloc_free(dict); return NULL; @@ -2928,7 +2928,7 @@ fr_dict_t *dict_alloc(TALLOC_CTX *ctx) */ dict->pool = talloc_pool(dict, DICT_POOL_SIZE); if (!dict->pool) { - fr_strerror_printf("Failed allocating talloc pool for dictionary"); + fr_strerror_const("Failed allocating talloc pool for dictionary"); goto error; } @@ -3042,7 +3042,7 @@ int fr_dict_enum_autoload(fr_dict_enum_autoload_t const *to_load) for (p = to_load; p->out; p++) { if (unlikely(!p->attr)) { - fr_strerror_printf("Invalid autoload entry, missing attribute pointer"); + fr_strerror_const("Invalid autoload entry, missing attribute pointer"); return -1; } @@ -3081,7 +3081,7 @@ int fr_dict_attr_autoload(fr_dict_attr_autoload_t const *to_load) for (p = to_load; p->out; p++) { if (!p->dict) { - fr_strerror_printf("Invalid autoload entry, missing dictionary pointer"); + fr_strerror_const("Invalid autoload entry, missing dictionary pointer"); return -1; } @@ -3128,7 +3128,7 @@ int fr_dict_autoload(fr_dict_autoload_t const *to_load) fr_dict_t *dict = NULL; if (unlikely(!p->proto)) { - fr_strerror_printf("autoload missing parameter proto"); + fr_strerror_const("autoload missing parameter proto"); return -1; } @@ -3266,7 +3266,7 @@ static int _dict_global_free(fr_dict_gctx_t *gctx) bool still_loaded = false; if (gctx->internal) { - fr_strerror_printf("Refusing to free dict gctx. Internal dictionary is still loaded"); + fr_strerror_const("Refusing to free dict gctx. Internal dictionary is still loaded"); still_loaded = true; } @@ -3305,19 +3305,19 @@ fr_dict_gctx_t const *fr_dict_global_ctx_init(TALLOC_CTX *ctx, char const *dict_ fr_dict_gctx_t *new_ctx; if (!dict_dir) { - fr_strerror_printf("No dictionary location provided"); + fr_strerror_const("No dictionary location provided"); return NULL; } new_ctx = talloc_zero(ctx, fr_dict_gctx_t); if (!new_ctx) { - fr_strerror_printf("Out of Memory"); + fr_strerror_const("Out of Memory"); return NULL; } new_ctx->protocol_by_name = fr_hash_table_create(new_ctx, dict_protocol_name_hash, dict_protocol_name_cmp, NULL); if (!new_ctx->protocol_by_name) { - fr_strerror_printf("Failed initializing protocol_by_name hash"); + fr_strerror_const("Failed initializing protocol_by_name hash"); error: talloc_free(new_ctx); return NULL; @@ -3325,7 +3325,7 @@ fr_dict_gctx_t const *fr_dict_global_ctx_init(TALLOC_CTX *ctx, char const *dict_ new_ctx->protocol_by_num = fr_hash_table_create(new_ctx, dict_protocol_num_hash, dict_protocol_num_cmp, NULL); if (!new_ctx->protocol_by_num) { - fr_strerror_printf("Failed initializing protocol_by_num hash"); + fr_strerror_const("Failed initializing protocol_by_num hash"); goto error; } @@ -3475,7 +3475,7 @@ ssize_t fr_dict_valid_name(char const *name, ssize_t len) if (len < 0) len = strlen(name); if (len > FR_DICT_ATTR_MAX_NAME_LEN) { - fr_strerror_printf("Attribute name is too long"); + fr_strerror_const("Attribute name is too long"); return -1; } diff --git a/src/lib/util/dict_validate.c b/src/lib/util/dict_validate.c index 3112df7f3c0..a55b2962f84 100644 --- a/src/lib/util/dict_validate.c +++ b/src/lib/util/dict_validate.c @@ -87,12 +87,12 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, } if (flags->is_unknown) { - fr_strerror_printf("The 'unknown' flag cannot be set for attributes in the dictionary."); + fr_strerror_const("The 'unknown' flag cannot be set for attributes in the dictionary."); return false; } if (flags->is_raw) { - fr_strerror_printf("The 'raw' flag cannot be set for attributes in the dictionary."); + fr_strerror_const("The 'raw' flag cannot be set for attributes in the dictionary."); return false; } @@ -147,12 +147,12 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, */ if (flags->virtual) { if (!parent->flags.is_root) { - fr_strerror_printf("The 'virtual' flag can only be used for normal attributes"); + fr_strerror_const("The 'virtual' flag can only be used for normal attributes"); return false; } if (attr && !flags->internal && (*attr <= (1 << (8 * parent->flags.type_size)))) { - fr_strerror_printf("The 'virtual' flag can only be used for non-protocol attributes"); + fr_strerror_const("The 'virtual' flag can only be used for non-protocol attributes"); return false; } @@ -167,7 +167,7 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, if (flags->extra) { if ((flags->subtype != FLAG_KEY_FIELD) && (flags->subtype != FLAG_LENGTH_UINT16) && (flags->subtype != FLAG_BIT_FIELD) && (flags->subtype != FLAG_HAS_REF)) { - fr_strerror_printf("The 'key' and 'length' flags cannot be used with any other flags."); + fr_strerror_const("The 'key' and 'length' flags cannot be used with any other flags."); return false; } @@ -178,12 +178,12 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, case FR_TYPE_UINT32: case FR_TYPE_UINT64: if ((flags->subtype != FLAG_KEY_FIELD) && (flags->subtype != FLAG_BIT_FIELD)) { - fr_strerror_printf("Invalid type for extra flag."); + fr_strerror_const("Invalid type for extra flag."); return false; } if (parent->type != FR_TYPE_STRUCT) { - fr_strerror_printf("The 'key' flag can only be used inside of a 'struct'."); + fr_strerror_const("The 'key' flag can only be used inside of a 'struct'."); return false; } @@ -193,14 +193,14 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, case FR_TYPE_OCTETS: if (flags->length != 0) { - fr_strerror_printf("Cannot use [..] and length=uint16"); + fr_strerror_const("Cannot use [..] and length=uint16"); return false; } FALL_THROUGH; case FR_TYPE_STRING: if (flags->subtype != FLAG_LENGTH_UINT16) { - fr_strerror_printf("Invalid type for extra flag."); + fr_strerror_const("Invalid type for extra flag."); return false; } @@ -211,7 +211,7 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, case FR_TYPE_STRUCT: if (flags->subtype != FLAG_LENGTH_UINT16) { - fr_strerror_printf("Invalid type for extra flag."); + fr_strerror_const("Invalid type for extra flag."); return false; } @@ -222,7 +222,7 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, case FR_TYPE_TLV: if (flags->subtype != FLAG_HAS_REF) { - fr_strerror_printf("Invalid type for extra flag."); + fr_strerror_const("Invalid type for extra flag."); return false; } @@ -321,7 +321,7 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, case FR_TYPE_STRUCT: ALLOW_FLAG(internal); if (all_flags) { - fr_strerror_printf("Invalid flag for attribute of type 'struct'"); + fr_strerror_const("Invalid flag for attribute of type 'struct'"); return false; } break; @@ -338,7 +338,7 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, if ((flags->length != 1) && (flags->length != 2) && (flags->length != 4)) { - fr_strerror_printf("The 'length' flag can only be used for attributes of type 'vendor' with lengths of 1,2 or 4"); + fr_strerror_const("The 'length' flag can only be used for attributes of type 'vendor' with lengths of 1,2 or 4"); return false; } @@ -367,7 +367,7 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, if ((flags->length != 1) && (flags->length != 2) && (flags->length != 4)) { - fr_strerror_printf("The 'length' flag can only be used for attributes of type 'tlv' with lengths of 1,2 or 4"); + fr_strerror_const("The 'length' flag can only be used for attributes of type 'tlv' with lengths of 1,2 or 4"); return false; } @@ -416,7 +416,7 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, ALLOW_FLAG(array); if (all_flags) { - fr_strerror_printf("The 'octets[...]' syntax cannot be used any other flag"); + fr_strerror_const("The 'octets[...]' syntax cannot be used any other flag"); return false; } @@ -429,7 +429,7 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, case FR_TYPE_COMBO_IP_ADDR: if (strcasecmp(dict->root->name, "RADIUS") != 0) { - fr_strerror_printf("The 'combo-ip' type can only be used in the RADIUS dictionary."); + fr_strerror_const("The 'combo-ip' type can only be used in the RADIUS dictionary."); return false; } @@ -443,7 +443,7 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, } if (!v) { - fr_strerror_printf("Attributes of type 'combo-ip' can only be used in VSA dictionaries"); + fr_strerror_const("Attributes of type 'combo-ip' can only be used in VSA dictionaries"); return false; } break; @@ -474,14 +474,14 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, } } else if (!flags->extra) { if ((type != FR_TYPE_TLV) && (type != FR_TYPE_VENDOR)) { - fr_strerror_printf("The 'format=' flag can only be used with attributes of type 'tlv'"); + fr_strerror_const("The 'format=' flag can only be used with attributes of type 'tlv'"); return false; } if ((flags->type_size != 1) && (flags->type_size != 2) && (flags->type_size != 4)) { - fr_strerror_printf("The 'format=' flag can only be used with attributes of type size 1,2 or 4"); + fr_strerror_const("The 'format=' flag can only be used with attributes of type size 1,2 or 4"); return false; } } @@ -495,7 +495,7 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, ALLOW_FLAG(extra); ALLOW_FLAG(subtype); if (all_flags) { - fr_strerror_printf("Invalid flag for attribute inside of a 'struct'"); + fr_strerror_const("Invalid flag for attribute inside of a 'struct'"); return false; } @@ -525,7 +525,7 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, */ if ((dict_attr_sizes[sibling->type][1] == ~(size_t) 0) && (sibling->flags.length == 0)) { - fr_strerror_printf("Only the last child of a 'struct' attribute can have variable length"); + fr_strerror_const("Only the last child of a 'struct' attribute can have variable length"); return false; } @@ -671,7 +671,7 @@ bool dict_attr_fields_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, case FR_TYPE_STRING: case FR_TYPE_OCTETS: if (flags->length != 0) { - fr_strerror_printf("The 'octets' type MUST be fixed-width when used inside of a 'struct'"); + fr_strerror_const("The 'octets' type MUST be fixed-width when used inside of a 'struct'"); return false; } break; diff --git a/src/lib/util/dl.c b/src/lib/util/dl.c index 44ec4430b6b..ae754079f27 100644 --- a/src/lib/util/dl.c +++ b/src/lib/util/dl.c @@ -693,7 +693,7 @@ int dl_search_path_set(dl_loader_t *dl_loader, char const *lib_dir) dl_loader->lib_dir = talloc_strdup(dl_loader, lib_dir); if (!dl_loader->lib_dir) { - fr_strerror_printf("Failed allocating memory for dl search path"); + fr_strerror_const("Failed allocating memory for dl search path"); return -1; } @@ -718,7 +718,7 @@ int dl_search_path_prepend(dl_loader_t *dl_loader, char const *lib_dir) dl_loader->lib_dir = talloc_strdup(dl_loader->lib_dir, lib_dir); if (!dl_loader->lib_dir) { oom: - fr_strerror_printf("Failed allocating memory for dl search path"); + fr_strerror_const("Failed allocating memory for dl search path"); return -1; } return 0; @@ -748,7 +748,7 @@ int dl_search_path_append(dl_loader_t *dl_loader, char const *lib_dir) dl_loader->lib_dir = talloc_strdup(dl_loader->lib_dir, lib_dir); if (!dl_loader->lib_dir) { oom: - fr_strerror_printf("Failed allocating memory for dl search path"); + fr_strerror_const("Failed allocating memory for dl search path"); return -1; } return 0; @@ -788,13 +788,13 @@ dl_loader_t *dl_loader_init(TALLOC_CTX *ctx, void *uctx, bool uctx_free, bool de dl_loader = talloc_zero(NULL, dl_loader_t); if (!dl_loader) { - fr_strerror_printf("Failed allocating dl_loader"); + fr_strerror_const("Failed allocating dl_loader"); return NULL; } dl_loader->tree = rbtree_talloc_alloc(dl_loader, dl_handle_cmp, dl_t, NULL, 0); if (!dl_loader->tree) { - fr_strerror_printf("Failed initialising dl->tree"); + fr_strerror_const("Failed initialising dl->tree"); error: TALLOC_FREE(dl_loader); return NULL; @@ -804,7 +804,7 @@ dl_loader_t *dl_loader_init(TALLOC_CTX *ctx, void *uctx, bool uctx_free, bool de dl_loader->lib_dir = talloc_strdup(dl_loader, fr_path_default_lib_dir()); if (!dl_loader->lib_dir) { - fr_strerror_printf("Failed allocating memory for dl search path"); + fr_strerror_const("Failed allocating memory for dl search path"); goto error; } diff --git a/src/lib/util/dns.c b/src/lib/util/dns.c index 4e56367b5e4..9a9dbdf505d 100644 --- a/src/lib/util/dns.c +++ b/src/lib/util/dns.c @@ -537,7 +537,7 @@ ssize_t fr_dns_label_from_value_box(size_t *need, uint8_t *buf, size_t buf_len, uint8_t *data; if (!buf || !buf_len || !where || !value) { - fr_strerror_printf("Invalid input"); + fr_strerror_const("Invalid input"); return -1; } @@ -545,7 +545,7 @@ ssize_t fr_dns_label_from_value_box(size_t *need, uint8_t *buf, size_t buf_len, * Don't allow stupidities */ if (!((where >= buf) && (where < (buf + buf_len)))) { - fr_strerror_printf("Label to write is outside of buffer"); + fr_strerror_const("Label to write is outside of buffer"); return -1; } @@ -553,7 +553,7 @@ ssize_t fr_dns_label_from_value_box(size_t *need, uint8_t *buf, size_t buf_len, * We can only encode strings. */ if (value->type != FR_TYPE_STRING) { - fr_strerror_printf("Asked to encode non-string type"); + fr_strerror_const("Asked to encode non-string type"); return -1; } @@ -582,7 +582,7 @@ ssize_t fr_dns_label_from_value_box(size_t *need, uint8_t *buf, size_t buf_len, last = q; if (*q == '.') { - fr_strerror_printf("Empty labels are invalid"); + fr_strerror_const("Empty labels are invalid"); return -1; } @@ -599,7 +599,7 @@ ssize_t fr_dns_label_from_value_box(size_t *need, uint8_t *buf, size_t buf_len, } if (q[1] == '.') { - fr_strerror_printf("Double dots '..' are forbidden"); + fr_strerror_const("Double dots '..' are forbidden"); return -1; } last = q; @@ -613,7 +613,7 @@ ssize_t fr_dns_label_from_value_box(size_t *need, uint8_t *buf, size_t buf_len, q++; if ((q - last) > 63) { - fr_strerror_printf("Label is larger than 63 characters"); + fr_strerror_const("Label is larger than 63 characters"); return -1; } } @@ -756,7 +756,7 @@ ssize_t fr_dns_label_uncompressed_length(uint8_t const *buf, size_t buf_len, uin * 0b10 and 0b10 are forbidden */ if ((*p > 63) && (*p < 0xc0)) { - fr_strerror_printf("Data with invalid high bits"); + fr_strerror_const("Data with invalid high bits"); return -(p - buf); } @@ -768,7 +768,7 @@ ssize_t fr_dns_label_uncompressed_length(uint8_t const *buf, size_t buf_len, uin if ((p + 2) > end) { overflow: - fr_strerror_printf("Label overflows buffer"); + fr_strerror_const("Label overflows buffer"); return -(p - buf); } @@ -845,7 +845,7 @@ ssize_t fr_dns_label_uncompressed_length(uint8_t const *buf, size_t buf_len, uin * DNS names can be no more than 255 octets. */ if (length > 255) { - fr_strerror_printf("Total length of labels is > 255"); + fr_strerror_const("Total length of labels is > 255"); return -(p - buf); } diff --git a/src/lib/util/event.c b/src/lib/util/event.c index 8eda812220e..e567d68225d 100644 --- a/src/lib/util/event.c +++ b/src/lib/util/event.c @@ -578,7 +578,7 @@ static ssize_t fr_event_build_evset(struct kevent out_kev[], size_t outlen, fr_e } while (1); if (out > end) { - fr_strerror_printf("Out of memory to store kevent filters"); + fr_strerror_const("Out of memory to store kevent filters"); return -1; } @@ -588,7 +588,7 @@ static ssize_t fr_event_build_evset(struct kevent out_kev[], size_t outlen, fr_e if (has_current_func && (!has_prev_func || (current_fflags != prev_fflags))) { if ((size_t)(add_p - add) >= (NUM_ELEMENTS(add))) { - fr_strerror_printf("Out of memory to store kevent EV_ADD filters"); + fr_strerror_const("Out of memory to store kevent EV_ADD filters"); return -1; } EVENT_DEBUG("\tEV_SET EV_ADD filter %s (%i), flags %i, fflags %i", @@ -775,7 +775,7 @@ int _fr_event_fd_move(NDEBUG_LOCATION_ARGS int ret; if (fr_event_loop_exiting(dst)) { - fr_strerror_printf("Destination event loop exiting"); + fr_strerror_const("Destination event loop exiting"); return -1; } @@ -909,7 +909,7 @@ int _fr_event_filter_insert(NDEBUG_LOCATION_ARGS struct kevent evset[10]; if (unlikely(!el)) { - fr_strerror_printf("Invalid argument: NULL event list"); + fr_strerror_const("Invalid argument: NULL event list"); return -1; } @@ -919,7 +919,7 @@ int _fr_event_filter_insert(NDEBUG_LOCATION_ARGS } if (unlikely(el->exit)) { - fr_strerror_printf("Event loop exiting"); + fr_strerror_const("Event loop exiting"); return -1; } @@ -945,7 +945,7 @@ int _fr_event_filter_insert(NDEBUG_LOCATION_ARGS if (!ef) { ef = talloc_zero(el, fr_event_fd_t); if (unlikely(!ef)) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } talloc_set_destructor(ef, _event_fd_delete); @@ -1062,7 +1062,7 @@ int _fr_event_fd_insert(NDEBUG_LOCATION_ARGS fr_event_io_func_t funcs = { .read = read_fn, .write = write_fn }; if (unlikely(!read_fn && !write_fn)) { - fr_strerror_printf("Invalid arguments: All callbacks are NULL"); + fr_strerror_const("Invalid arguments: All callbacks are NULL"); return -1; } @@ -1227,22 +1227,22 @@ int _fr_event_timer_at(NDEBUG_LOCATION_ARGS fr_event_timer_t *ev; if (unlikely(!el)) { - fr_strerror_printf("Invalid arguments: NULL event list"); + fr_strerror_const("Invalid arguments: NULL event list"); return -1; } if (unlikely(!callback)) { - fr_strerror_printf("Invalid arguments: NULL callback"); + fr_strerror_const("Invalid arguments: NULL callback"); return -1; } if (unlikely(!ev_p)) { - fr_strerror_printf("Invalid arguments: NULL ev_p"); + fr_strerror_const("Invalid arguments: NULL ev_p"); return -1; } if (unlikely(el->exit)) { - fr_strerror_printf("Event loop exiting"); + fr_strerror_const("Event loop exiting"); return -1; } @@ -1327,7 +1327,7 @@ int _fr_event_timer_at(NDEBUG_LOCATION_ARGS */ if (!fr_dlist_entry_in_list(&ev->entry)) fr_dlist_insert_head(&el->ev_to_add, ev); } else if (unlikely(fr_heap_insert(el->times, ev) < 0)) { - fr_strerror_printf_push("Failed inserting event"); + fr_strerror_const_push("Failed inserting event"); talloc_set_destructor(ev, NULL); *ev_p = NULL; talloc_free(ev); @@ -1745,7 +1745,7 @@ int fr_event_corral(fr_event_list_t *el, fr_time_t now, bool wait) if (el->will_exit || el->exit) { el->exit = el->will_exit; - fr_strerror_printf("Event loop exiting"); + fr_strerror_const("Event loop exiting"); return -1; } @@ -2260,7 +2260,7 @@ fr_event_list_t *fr_event_list_alloc(TALLOC_CTX *ctx, fr_event_status_cb_t statu el = talloc_zero(ctx, fr_event_list_t); if (!fr_cond_assert(el)) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return NULL; } el->time = fr_time; @@ -2269,7 +2269,7 @@ fr_event_list_t *fr_event_list_alloc(TALLOC_CTX *ctx, fr_event_status_cb_t statu el->times = fr_heap_talloc_alloc(el, fr_event_timer_cmp, fr_event_timer_t, heap_id); if (!el->times) { - fr_strerror_printf("Failed allocating event heap"); + fr_strerror_const("Failed allocating event heap"); error: talloc_free(el); return NULL; @@ -2277,14 +2277,14 @@ fr_event_list_t *fr_event_list_alloc(TALLOC_CTX *ctx, fr_event_status_cb_t statu el->fds = rbtree_talloc_alloc(el, fr_event_fd_cmp, fr_event_fd_t, NULL, 0); if (!el->fds) { - fr_strerror_printf("Failed allocating FD tree"); + fr_strerror_const("Failed allocating FD tree"); goto error; } #ifdef LOCAL_PID el->pids = fr_heap_talloc_alloc(el, fr_event_pid_cmp, fr_event_pid_t, heap_id); if (!el->pids) { - fr_strerror_printf("Failed allocating PID heap"); + fr_strerror_const("Failed allocating PID heap"); goto error; } #endif diff --git a/src/lib/util/ext.c b/src/lib/util/ext.c index ed60a1f033e..02e94393930 100644 --- a/src/lib/util/ext.c +++ b/src/lib/util/ext.c @@ -82,7 +82,7 @@ void *fr_ext_alloc_size(fr_ext_t const *def, void **chunk_p, int ext, size_t ext chunk_len = talloc_get_size(chunk); offset = ROUND_UP_DIV(chunk_len, FR_EXT_ALIGNMENT); if (unlikely(offset > UINT8_MAX)) { - fr_strerror_printf("Insufficient space remaining for extensions"); + fr_strerror_const("Insufficient space remaining for extensions"); return NULL; } @@ -168,7 +168,7 @@ void *fr_ext_copy(fr_ext_t const *def, TALLOC_CTX **chunk_dst, TALLOC_CTX const fr_ext_info_t const *info = &def->info[ext]; if (!info->can_copy) { - fr_strerror_printf("Extension cannot be copied"); + fr_strerror_const("Extension cannot be copied"); return NULL; } diff --git a/src/lib/util/file.c b/src/lib/util/file.c index 7052e769fa2..ac472d5e0a8 100644 --- a/src/lib/util/file.c +++ b/src/lib/util/file.c @@ -181,7 +181,7 @@ ssize_t fr_mkdir(int *fd_out, char const *path, ssize_t len, mode_t mode, fr_mkd */ our_path = talloc_bstrndup(NULL, path, (size_t)len); if (!our_path) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } @@ -237,7 +237,7 @@ char *fr_realpath(TALLOC_CTX *ctx, char const *path, ssize_t len) talloc_abs_path = talloc_strdup(ctx, abs_path); free(abs_path); if (!talloc_abs_path) { - fr_strerror_printf("Out of Memory"); + fr_strerror_const("Out of Memory"); return NULL; } diff --git a/src/lib/util/heap.c b/src/lib/util/heap.c index b4b2194836a..7a6c40e4386 100644 --- a/src/lib/util/heap.c +++ b/src/lib/util/heap.c @@ -129,7 +129,7 @@ int fr_heap_insert(fr_heap_t *hp, void *data) */ child = index_get(hp, data); if ((child > 0) || ((child == 0) && (hp->num_elements > 0) && (data == hp->p[0]))) { - fr_strerror_printf("Node is already in the heap"); + fr_strerror_const("Node is already in the heap"); return -1; } @@ -154,7 +154,7 @@ int fr_heap_insert(fr_heap_t *hp, void *data) */ if (n_size > INT32_MAX) { if (hp->size == INT32_MAX) { - fr_strerror_printf("Heap is full"); + fr_strerror_const("Heap is full"); return -1; } else { n_size = INT32_MAX; @@ -220,7 +220,7 @@ int fr_heap_extract(fr_heap_t *hp, void *data) */ if (!data) { if (unlikely((hp->num_elements == 0) || !hp->p[0])) { - fr_strerror_printf("Tried to extract element from empty heap"); + fr_strerror_const("Tried to extract element from empty heap"); return -1; } parent = 0; diff --git a/src/lib/util/inet.c b/src/lib/util/inet.c index 6af5a0f8a22..41ebbd49661 100644 --- a/src/lib/util/inet.c +++ b/src/lib/util/inet.c @@ -75,7 +75,7 @@ int fr_ipaddr_is_inaddr_any(fr_ipaddr_t const *ipaddr) #endif } else { - fr_strerror_printf("Unknown address family"); + fr_strerror_const("Unknown address family"); return -1; } @@ -105,7 +105,7 @@ int fr_ipaddr_is_multicast(fr_ipaddr_t const *ipaddr) #endif } else { - fr_strerror_printf("Unknown address family"); + fr_strerror_const("Unknown address family"); return -1; } @@ -130,7 +130,7 @@ int fr_ipaddr_is_prefix(fr_ipaddr_t const *ipaddr) return (ipaddr->prefix < 128); default: - fr_strerror_printf("Unknown address family"); + fr_strerror_const("Unknown address family"); return -1; } } @@ -321,7 +321,7 @@ int fr_inet_hton(fr_ipaddr_t *out, int af, char const *hostname, bool fallback) ret = fr_ipaddr_from_sockaddr(out, NULL, (struct sockaddr_storage *)ai->ai_addr, ai->ai_addrlen); freeaddrinfo(res); if (ret < 0) { - fr_strerror_printf("Failed converting sockaddr to ipaddr"); + fr_strerror_const("Failed converting sockaddr to ipaddr"); return -1; } @@ -479,7 +479,7 @@ int fr_inet_pton4(fr_ipaddr_t *out, char const *value, ssize_t inlen, bool resol end = value + inlen; while (isspace((int) *value) && (value < end)) value++; if (value == end) { - fr_strerror_printf("Empty IPv4 address string is invalid"); + fr_strerror_const("Empty IPv4 address string is invalid"); return -1; } inlen = end - value; @@ -616,7 +616,7 @@ int fr_inet_pton6(fr_ipaddr_t *out, char const *value, ssize_t inlen, bool resol end = value + inlen; while (isspace((int) *value) && (value < end)) value++; if (value == end) { - fr_strerror_printf("Empty IPv4 address string is invalid"); + fr_strerror_const("Empty IPv4 address string is invalid"); return -1; } inlen = end - value; @@ -732,7 +732,7 @@ int fr_inet_pton(fr_ipaddr_t *out, char const *value, ssize_t inlen, int af, boo end = value + inlen; while (isspace((int) *value) && (value < end)) value++; if (value == end) { - fr_strerror_printf("Empty IPv4 address string is invalid"); + fr_strerror_const("Empty IPv4 address string is invalid"); return -1; } inlen = end - value; @@ -808,7 +808,7 @@ int fr_inet_pton(fr_ipaddr_t *out, char const *value, ssize_t inlen, int af, boo * asked to do DNS resolution, we can't do it. */ if (!resolve) { - fr_strerror_printf("Not IPv4/6 address, and asked not to resolve"); + fr_strerror_const("Not IPv4/6 address, and asked not to resolve"); return -1; } @@ -817,7 +817,7 @@ int fr_inet_pton(fr_ipaddr_t *out, char const *value, ssize_t inlen, int af, boo * early. */ if (!hostname) { - fr_strerror_printf("Invalid address"); + fr_strerror_const("Invalid address"); return -1; } } @@ -829,7 +829,7 @@ int fr_inet_pton(fr_ipaddr_t *out, char const *value, ssize_t inlen, int af, boo */ if (ipv6 && !hostname) { if (af == AF_INET) { - fr_strerror_printf("Invalid address"); + fr_strerror_const("Invalid address"); return -1; } @@ -895,7 +895,7 @@ int fr_inet_pton_port(fr_ipaddr_t *out, uint16_t *port_out, char const *value, if (*p == '[') { if (!(q = memchr(p + 1, ']', len - 1))) { - fr_strerror_printf("Missing closing ']' for IPv6 address"); + fr_strerror_const("Missing closing ']' for IPv6 address"); return -1; } @@ -930,7 +930,7 @@ do_port: */ if (len > (size_t) ((q + sizeof(buffer)) - value)) { error: - fr_strerror_printf("IP string contains trailing garbage after port delimiter"); + fr_strerror_const("IP string contains trailing garbage after port delimiter"); return -1; } @@ -1377,7 +1377,7 @@ int fr_ipaddr_from_sockaddr(fr_ipaddr_t *ipaddr, uint16_t *port, struct sockaddr_in s4; if (salen < sizeof(s4)) { - fr_strerror_printf("IPv4 address is too small"); + fr_strerror_const("IPv4 address is too small"); return 0; } @@ -1393,7 +1393,7 @@ int fr_ipaddr_from_sockaddr(fr_ipaddr_t *ipaddr, uint16_t *port, struct sockaddr_in6 s6; if (salen < sizeof(s6)) { - fr_strerror_printf("IPv6 address is too small"); + fr_strerror_const("IPv6 address is too small"); return 0; } diff --git a/src/lib/util/md4.c b/src/lib/util/md4.c index 10b8c01080b..bbfae47a073 100644 --- a/src/lib/util/md4.c +++ b/src/lib/util/md4.c @@ -76,7 +76,7 @@ static fr_md4_ctx_t *fr_md4_openssl_ctx_alloc(bool thread_local) md_ctx = EVP_MD_CTX_new(); if (unlikely(!md_ctx)) { oom: - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return NULL; } fr_thread_local_set_destructor(md4_ctx, _md4_ctx_openssl_free_on_exit, md_ctx); diff --git a/src/lib/util/md5.c b/src/lib/util/md5.c index 07a796d31e1..2423a240626 100644 --- a/src/lib/util/md5.c +++ b/src/lib/util/md5.c @@ -100,7 +100,7 @@ static fr_md5_ctx_t *fr_md5_openssl_ctx_alloc(bool thread_local) md_ctx = EVP_MD_CTX_new(); if (unlikely(!md_ctx)) { oom: - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return NULL; } EVP_DigestInit_ex(md_ctx, EVP_md5(), NULL); diff --git a/src/lib/util/misc.c b/src/lib/util/misc.c index 834aee510e7..b76731230ec 100644 --- a/src/lib/util/misc.c +++ b/src/lib/util/misc.c @@ -297,12 +297,12 @@ int fr_blocking(int fd) #else int fr_nonblock(UNUSED int fd) { - fr_strerror_printf("Non blocking sockets are not supported"); + fr_strerror_const("Non blocking sockets are not supported"); return -1; } int fr_blocking(UNUSED int fd) { - fr_strerror_printf("Non blocking sockets are not supported"); + fr_strerror_const("Non blocking sockets are not supported"); return -1; } #endif @@ -379,7 +379,7 @@ ssize_t fr_writev(int fd, struct iovec vector[], int iovcnt, fr_time_delta_t tim /* Select returned 0 which means it reached the timeout */ if (ret == 0) { - fr_strerror_printf("Write timed out"); + fr_strerror_const("Write timed out"); return -1; } @@ -627,7 +627,7 @@ int fr_unix_time_from_str(fr_unix_time_t *date, char const *date_str) p++; subseconds = strtoul(p, &tail, 10); if (subseconds > NSEC) { - fr_strerror_printf("Invalid nanosecond specifier"); + fr_strerror_const("Invalid nanosecond specifier"); return -1; } @@ -727,7 +727,7 @@ int fr_unix_time_from_str(fr_unix_time_t *date, char const *date_str) f[2] = mystrtok(&p, " \t"); f[3] = mystrtok(&p, " \t"); /* may, or may not, be present */ if (!f[0] || !f[1] || !f[2]) { - fr_strerror_printf("Too few fields"); + fr_strerror_const("Too few fields"); return -1; } @@ -783,7 +783,7 @@ int fr_unix_time_from_str(fr_unix_time_t *date, char const *date_str) /* month not found? */ if (tm->tm_mon == 12) { - fr_strerror_printf("No month found"); + fr_strerror_const("No month found"); return -1; } @@ -802,7 +802,7 @@ int fr_unix_time_from_str(fr_unix_time_t *date, char const *date_str) * impossible to tell what's the day, and what's the year. */ if (tm->tm_mday < 1900) { - fr_strerror_printf("Invalid year < 1900"); + fr_strerror_const("Invalid year < 1900"); return -1; } @@ -818,7 +818,7 @@ int fr_unix_time_from_str(fr_unix_time_t *date, char const *date_str) * If the day is out of range, die. */ if ((tm->tm_mday < 1) || (tm->tm_mday > 31)) { - fr_strerror_printf("Invalid day of month"); + fr_strerror_const("Invalid day of month"); return -1; } @@ -829,7 +829,7 @@ int fr_unix_time_from_str(fr_unix_time_t *date, char const *date_str) f[0] = f[3]; /* HH */ f[1] = strchr(f[0], ':'); /* find : separator */ if (!f[1]) { - fr_strerror_printf("No ':' after hour"); + fr_strerror_const("No ':' after hour"); return -1; } @@ -880,7 +880,7 @@ int fr_size_from_str(size_t *out, char const *str) switch (tolower(q[0])) { case 'n': /* nibble */ if (size & 0x01) { - fr_strerror_printf("Sizes specified in nibbles must be an even number"); + fr_strerror_const("Sizes specified in nibbles must be an even number"); return -1; } size /= 2; diff --git a/src/lib/util/packet.c b/src/lib/util/packet.c index 5ae4cf41e1e..87fd741a33b 100644 --- a/src/lib/util/packet.c +++ b/src/lib/util/packet.c @@ -44,7 +44,7 @@ fr_radius_packet_t *fr_radius_alloc(TALLOC_CTX *ctx, bool new_vector) rp = talloc_zero(ctx, fr_radius_packet_t); if (!rp) { - fr_strerror_printf("out of memory"); + fr_strerror_const("out of memory"); return NULL; } rp->id = -1; diff --git a/src/lib/util/pair.c b/src/lib/util/pair.c index d063b1405a3..b1e11ea2c5c 100644 --- a/src/lib/util/pair.c +++ b/src/lib/util/pair.c @@ -108,7 +108,7 @@ fr_pair_t *fr_pair_alloc_null(TALLOC_CTX *ctx) vp = talloc_zero(ctx, fr_pair_t); if (!vp) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return NULL; } @@ -137,7 +137,7 @@ fr_pair_t *fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da) vp = fr_pair_alloc_null(ctx); if (!vp) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return NULL; } @@ -1316,7 +1316,7 @@ int fr_pair_list_copy_by_da(TALLOC_CTX *ctx, fr_pair_list_t *to, if (count == 0) count = UINT_MAX; if (unlikely(!da)) { - fr_strerror_printf("No search attribute provided"); + fr_strerror_const("No search attribute provided"); return -1; } @@ -1373,7 +1373,7 @@ int fr_pair_list_copy_by_ancestor(TALLOC_CTX *ctx, fr_pair_list_t *to, if (count == 0) count = UINT_MAX; if (unlikely(!parent_da)) { - fr_strerror_printf("No search attribute provided"); + fr_strerror_const("No search attribute provided"); return -1; } diff --git a/src/lib/util/pair_legacy.c b/src/lib/util/pair_legacy.c index b82c9159c81..7b132efe765 100644 --- a/src/lib/util/pair_legacy.c +++ b/src/lib/util/pair_legacy.c @@ -76,13 +76,13 @@ int fr_pair_mark_xlat(fr_pair_t *vp, char const *value) * valuepair should not already have a value. */ if (vp->type != VT_NONE) { - fr_strerror_printf("Pair already has a value"); + fr_strerror_const("Pair already has a value"); return -1; } raw = talloc_typed_strdup(vp, value); if (!raw) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } @@ -185,7 +185,7 @@ fr_pair_t *fr_pair_make(TALLOC_CTX *ctx, fr_dict_t const *dict, fr_pair_list_t * } if (da->type == FR_TYPE_GROUP) { - fr_strerror_printf("Attributes of type 'group' are not supported"); + fr_strerror_const("Attributes of type 'group' are not supported"); return NULL; } @@ -209,7 +209,7 @@ fr_pair_t *fr_pair_make(TALLOC_CTX *ctx, fr_dict_t const *dict, fr_pair_list_t * case T_OP_REG_NE: /* !~ */ { #ifndef HAVE_REGEX - fr_strerror_printf("Regular expressions are not supported"); + fr_strerror_const("Regular expressions are not supported"); return NULL; #else ssize_t slen; @@ -350,7 +350,7 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const * if ((size_t) (next - p) >= sizeof(raw.l_opand)) { fr_dict_unknown_free(&da); - fr_strerror_printf("Attribute name too long"); + fr_strerror_const("Attribute name too long"); goto error; } @@ -367,7 +367,7 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const * raw.op = gettoken(&p, raw.r_opand, sizeof(raw.r_opand), false); if ((raw.op < T_EQSTART) || (raw.op > T_EQEND)) { fr_dict_unknown_free(&da); - fr_strerror_printf("Expecting operator"); + fr_strerror_const("Expecting operator"); goto error; } @@ -400,7 +400,7 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const * if (last_token != T_RCBRACE) { failed_group: - fr_strerror_printf("Failed to end group list with '}'"); + fr_strerror_const("Failed to end group list with '}'"); talloc_free(vp); goto error; } @@ -419,7 +419,7 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const * */ quote = gettoken(&p, raw.r_opand, sizeof(raw.r_opand), false); if (quote == T_EOL) { - fr_strerror_printf("Failed to get value"); + fr_strerror_const("Failed to get value"); goto error; } diff --git a/src/lib/util/pair_tokenize.c b/src/lib/util/pair_tokenize.c index afc18a49508..495aa9d5586 100644 --- a/src/lib/util/pair_tokenize.c +++ b/src/lib/util/pair_tokenize.c @@ -42,7 +42,7 @@ static ssize_t op_to_token(fr_token_t *token, char const *op, size_t oplen) switch (*p) { default: - fr_strerror_printf("Invalid text. Expected comparison operator"); + fr_strerror_const("Invalid text. Expected comparison operator"); return -(p - op); case '!': @@ -64,7 +64,7 @@ static ssize_t op_to_token(fr_token_t *token, char const *op, size_t oplen) } else { invalid_operator: - fr_strerror_printf("Invalid operator"); + fr_strerror_const("Invalid operator"); return -(p - op); } break; @@ -202,14 +202,14 @@ static ssize_t fr_pair_afrom_str(fr_pair_ctx_t *pair_ctx, char const *start, cha p = in + slen; if (p >= end) { - fr_strerror_printf("Attribute name overflows the input buffer"); + fr_strerror_const("Attribute name overflows the input buffer"); return -(in - start); } while ((isspace((int) *p)) && (p < end)) p++; if (p >= end) { - fr_strerror_printf("No operator found in the input buffer"); + fr_strerror_const("No operator found in the input buffer"); return -(p - start); } @@ -218,7 +218,7 @@ static ssize_t fr_pair_afrom_str(fr_pair_ctx_t *pair_ctx, char const *start, cha */ slen = op_to_token(&op, p, (end - p)); if (slen <= 0) { - fr_strerror_printf("Syntax error: expected '='"); + fr_strerror_const("Syntax error: expected '='"); return slen - -(p - start); } p += slen; @@ -226,12 +226,12 @@ static ssize_t fr_pair_afrom_str(fr_pair_ctx_t *pair_ctx, char const *start, cha while ((isspace((int) *p)) && (p < end)) p++; if (p >= end) { - fr_strerror_printf("No value found in the input buffer"); + fr_strerror_const("No value found in the input buffer"); return -(p - start); } if (*p == '`') { - fr_strerror_printf("Invalid string quotation"); + fr_strerror_const("Invalid string quotation"); return -(p - start); } @@ -257,7 +257,7 @@ static ssize_t fr_pair_afrom_str(fr_pair_ctx_t *pair_ctx, char const *start, cha } if (p > end) { - fr_strerror_printf("Value overflows the input buffer"); + fr_strerror_const("Value overflows the input buffer"); return -(p - start); } @@ -315,7 +315,7 @@ static ssize_t fr_pair_ctx_set(fr_pair_ctx_t *pair_ctx, char const *in, size_t i } if ((p + slen) > end) { - fr_strerror_printf("Attribute name overflows the input buffer"); + fr_strerror_const("Attribute name overflows the input buffer"); return -(p - in); } @@ -333,7 +333,7 @@ static ssize_t fr_pair_ctx_set(fr_pair_ctx_t *pair_ctx, char const *in, size_t i * We now MUST have FOO.BAR */ if (*p != '.') { - fr_strerror_printf("Unexpected text after attribute"); + fr_strerror_const("Unexpected text after attribute"); return -(p - in); } p++; @@ -458,7 +458,7 @@ ssize_t fr_pair_ctx_afrom_str(fr_pair_ctx_t *pair_ctx, char const *in, size_t in if ((p >= end) || (*p == ',')) return p - in; if (*p != '.') { - fr_strerror_printf("Unexpected text"); + fr_strerror_const("Unexpected text"); return - (p - in); } diff --git a/src/lib/util/pcap.c b/src/lib/util/pcap.c index fe1dcd9614c..ceb4eac4fc0 100644 --- a/src/lib/util/pcap.c +++ b/src/lib/util/pcap.c @@ -308,7 +308,7 @@ int fr_pcap_open(fr_pcap_t *pcap) } pcap->handle = pcap_open_dead(pcap->link_layer, SNAPLEN); if (!pcap->handle) { - fr_strerror_printf("Unknown error occurred opening dead PCAP handle"); + fr_strerror_const("Unknown error occurred opening dead PCAP handle"); return -1; } @@ -333,7 +333,7 @@ int fr_pcap_open(fr_pcap_t *pcap) break; #else case PCAP_STDIO_IN: - fr_strerror_printf("This version of libpcap does not support reading pcap data from streams"); + fr_strerror_const("This version of libpcap does not support reading pcap data from streams"); return -1; #endif @@ -349,7 +349,7 @@ int fr_pcap_open(fr_pcap_t *pcap) break; #else case PCAP_STDIO_OUT: - fr_strerror_printf("This version of libpcap does not support writing pcap data to streams"); + fr_strerror_const("This version of libpcap does not support writing pcap data to streams"); return -1; #endif @@ -388,7 +388,7 @@ int fr_pcap_apply_filter(fr_pcap_t *pcap, char const *expression) */ #ifdef DLT_NFLOG if (pcap->link_layer == DLT_NFLOG) { - fr_strerror_printf("NFLOG link-layer type filtering not implemented"); + fr_strerror_const("NFLOG link-layer type filtering not implemented"); return 1; } @@ -569,7 +569,7 @@ ssize_t fr_pcap_link_layer_offset(uint8_t const *data, size_t len, int link_laye goto done; } } - fr_strerror_printf("Exceeded maximum level of VLAN tag nesting (2)"); + fr_strerror_const("Exceeded maximum level of VLAN tag nesting (2)"); return -1; } diff --git a/src/lib/util/print.c b/src/lib/util/print.c index 641ec2647d0..2600f16731b 100644 --- a/src/lib/util/print.c +++ b/src/lib/util/print.c @@ -703,7 +703,7 @@ char *fr_vasprintf(TALLOC_CTX *ctx, char const *fmt, va_list ap) talloc_free(sub_fmt); if (!out_tmp) { oom: - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); talloc_free(out); talloc_free(subst); va_end(ap_p); @@ -880,7 +880,7 @@ ssize_t fr_fprintf(FILE *fp, char const *fmt, ...) int ret; if (!fp) { - fr_strerror_printf("Invalid 'fp'"); + fr_strerror_const("Invalid 'fp'"); return -1; } diff --git a/src/lib/util/rbtree.c b/src/lib/util/rbtree.c index 24458c25638..cd780a3a588 100644 --- a/src/lib/util/rbtree.c +++ b/src/lib/util/rbtree.c @@ -346,7 +346,7 @@ rbnode_t *rbtree_insert_node(rbtree_t *tree, void *data) /* setup new node */ x = talloc_zero(tree->node_ctx, rbnode_t); if (!x) { - fr_strerror_printf("No memory for new rbtree node"); + fr_strerror_const("No memory for new rbtree node"); if (tree->lock) pthread_mutex_unlock(&tree->mutex); return NULL; } diff --git a/src/lib/util/regex.c b/src/lib/util/regex.c index 2bd0644ab93..b949385102f 100644 --- a/src/lib/util/regex.c +++ b/src/lib/util/regex.c @@ -131,13 +131,13 @@ static int fr_pcre2_tls_init(void) tls->gcontext = pcre2_general_context_create(_pcre2_talloc, _pcre2_talloc_free, NULL); if (!tls->gcontext) { - fr_strerror_printf("Failed allocating general context"); + fr_strerror_const("Failed allocating general context"); return -1; } tls->ccontext = pcre2_compile_context_create(tls->gcontext); if (!tls->ccontext) { - fr_strerror_printf("Failed allocating compile context"); + fr_strerror_const("Failed allocating compile context"); error: fr_pcre2_tls = NULL; _pcre2_tls_free(tls); @@ -146,7 +146,7 @@ static int fr_pcre2_tls_init(void) tls->mcontext = pcre2_match_context_create(tls->gcontext); if (!tls->mcontext) { - fr_strerror_printf("Failed allocating match context"); + fr_strerror_const("Failed allocating match context"); goto error; } @@ -155,7 +155,7 @@ static int fr_pcre2_tls_init(void) if (tls->do_jit) { tls->jit_stack = pcre2_jit_stack_create(FR_PCRE_JIT_STACK_MIN, FR_PCRE_JIT_STACK_MAX, tls->gcontext); if (!tls->jit_stack) { - fr_strerror_printf("Failed allocating JIT stack"); + fr_strerror_const("Failed allocating JIT stack"); goto error; } pcre2_jit_stack_assign(tls->mcontext, NULL, tls->jit_stack); @@ -223,7 +223,7 @@ ssize_t regex_compile(TALLOC_CTX *ctx, regex_t **out, char const *pattern, size_ if (unlikely(!fr_pcre2_tls) && (fr_pcre2_tls_init() < 0)) return -1; if (len == 0) { - fr_strerror_printf("Empty expression"); + fr_strerror_const("Empty expression"); return 0; } @@ -348,7 +348,7 @@ int regex_exec(regex_t *preg, char const *subject, size_t len, fr_regmatch_t *re */ subject = our_subject = talloc_bstrndup(regmatch, subject, len); if (!subject) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } #ifndef NDEBUG @@ -365,7 +365,7 @@ int regex_exec(regex_t *preg, char const *subject, size_t len, fr_regmatch_t *re if (!regmatch) { match_data = pcre2_match_data_create_from_pattern(preg->compiled, fr_pcre2_tls->gcontext); if (!match_data) { - fr_strerror_printf("Failed allocating temporary match data"); + fr_strerror_const("Failed allocating temporary match data"); return -1; } } else { @@ -456,7 +456,7 @@ int regex_substitute(TALLOC_CTX *ctx, char **out, size_t max_out, regex_t *preg, */ subject = our_subject = talloc_bstrndup(regmatch, subject, subject_len); if (!subject) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } #else @@ -485,7 +485,7 @@ int regex_substitute(TALLOC_CTX *ctx, char **out, size_t max_out, regex_t *preg, #ifndef PCRE2_COPY_MATCHED_SUBJECT talloc_free(our_subject); #endif - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } @@ -527,7 +527,7 @@ again: * an actual error. */ if (actual_len == buff_len) { - fr_strerror_printf("libpcre2 out of memory"); + fr_strerror_const("libpcre2 out of memory"); return -1; } @@ -556,7 +556,7 @@ again: if (actual_len < (buff_len - 1)) { buff = talloc_bstr_realloc(ctx, buff, actual_len); if (!buff) { - fr_strerror_printf("reallocing pcre2_substitute result buffer failed"); + fr_strerror_const("reallocing pcre2_substitute result buffer failed"); return -1; } } @@ -579,7 +579,7 @@ uint32_t regex_subcapture_count(regex_t const *preg) uint32_t count; if (pcre2_pattern_info(preg->compiled, PCRE2_INFO_CAPTURECOUNT, &count) != 0) { - fr_strerror_printf("Error determining subcapture group count"); + fr_strerror_const("Error determining subcapture group count"); return 0; } @@ -616,7 +616,7 @@ fr_regmatch_t *regex_match_data_alloc(TALLOC_CTX *ctx, uint32_t count) regmatch = talloc(ctx, fr_regmatch_t); if (!regmatch) { oom: - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return NULL; } @@ -740,7 +740,7 @@ ssize_t regex_compile(TALLOC_CTX *ctx, regex_t **out, char const *pattern, size_ *out = NULL; if (len == 0) { - fr_strerror_printf("Empty expression"); + fr_strerror_const("Empty expression"); return 0; } @@ -749,7 +749,7 @@ ssize_t regex_compile(TALLOC_CTX *ctx, regex_t **out, char const *pattern, size_ */ if (flags) { if (flags->global) { - fr_strerror_printf("g - Global matching/substitution not supported with libpcre"); + fr_strerror_const("g - Global matching/substitution not supported with libpcre"); return 0; } if (flags->ignore_case) cflags |= PCRE_CASELESS; @@ -881,7 +881,7 @@ int regex_exec(regex_t *preg, char const *subject, size_t len, fr_regmatch_t *re fr_thread_local_set_destructor(fr_pcre_jit_stack, _pcre_jit_stack_free, pcre_jit_stack_alloc(FR_PCRE_JIT_STACK_MIN, FR_PCRE_JIT_STACK_MAX)); if (!fr_pcre_jit_stack) { - fr_strerror_printf("Allocating JIT stack failed"); + fr_strerror_const("Allocating JIT stack failed"); return -1; } } @@ -930,7 +930,7 @@ int regex_exec(regex_t *preg, char const *subject, size_t len, fr_regmatch_t *re if (regmatch->subject) talloc_const_free(regmatch->subject); regmatch->subject = talloc_bstrndup(regmatch, subject, len); if (!regmatch->subject) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } } @@ -949,7 +949,7 @@ uint32_t regex_subcapture_count(regex_t const *preg) int count; if (pcre_fullinfo(preg->compiled, preg->extra, PCRE_INFO_CAPTURECOUNT, &count) != 0) { - fr_strerror_printf("Error determining subcapture group count"); + fr_strerror_const("Error determining subcapture group count"); return 0; } @@ -1012,7 +1012,7 @@ ssize_t regex_compile(TALLOC_CTX *ctx, regex_t **out, char const *pattern, size_ regex_t *preg; if (len == 0) { - fr_strerror_printf("Empty expression"); + fr_strerror_const("Empty expression"); return 0; } @@ -1021,19 +1021,19 @@ ssize_t regex_compile(TALLOC_CTX *ctx, regex_t **out, char const *pattern, size_ */ if (flags) { if (flags->global) { - fr_strerror_printf("g - Global matching/substitution not supported with posix-regex"); + fr_strerror_const("g - Global matching/substitution not supported with posix-regex"); return 0; } if (flags->dot_all) { - fr_strerror_printf("s - Single line matching is not supported with posix-regex"); + fr_strerror_const("s - Single line matching is not supported with posix-regex"); return 0; } if (flags->unicode) { - fr_strerror_printf("u - Unicode matching not supported with posix-regex"); + fr_strerror_const("u - Unicode matching not supported with posix-regex"); return 0; } if (flags->extended) { - fr_strerror_printf("x - Whitespace and comments not supported with posix-regex"); + fr_strerror_const("x - Whitespace and comments not supported with posix-regex"); return 0; } @@ -1161,7 +1161,7 @@ int regex_exec(regex_t *preg, char const *subject, size_t len, fr_regmatch_t *re if (regmatch->subject) talloc_const_free(regmatch->subject); regmatch->subject = talloc_bstrndup(regmatch, subject, len); if (!regmatch->subject) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } } @@ -1199,7 +1199,7 @@ fr_regmatch_t *regex_match_data_alloc(TALLOC_CTX *ctx, uint32_t count) regmatch = talloc_zero_pooled_object(ctx, fr_regmatch_t, 2, (sizeof(regmatch_t) * count) + 128); if (unlikely(!regmatch)) { error: - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); talloc_free(regmatch); return NULL; } diff --git a/src/lib/util/sbuff.c b/src/lib/util/sbuff.c index fdd65094cf8..86ae6eb1c42 100644 --- a/src/lib/util/sbuff.c +++ b/src/lib/util/sbuff.c @@ -1337,7 +1337,7 @@ static inline CC_HINT(always_inline) int sbuff_scratch_init(TALLOC_CTX **out) if (!scratch) { scratch = talloc_pool(NULL, 4096); if (unlikely(!scratch)) { - fr_strerror_printf("Out of Memory"); + fr_strerror_const("Out of Memory"); return -1; } fr_thread_local_set_destructor(sbuff_scratch, _sbuff_scratch_free, scratch); diff --git a/src/lib/util/socket.c b/src/lib/util/socket.c index d4dd34f698c..58f7c2cc553 100644 --- a/src/lib/util/socket.c +++ b/src/lib/util/socket.c @@ -58,7 +58,7 @@ static int socket_port_from_service(int proto, char const *port_name) char const *proto_name; if (!port_name) { - fr_strerror_printf("No port specified"); + fr_strerror_const("No port specified"); return -1; } @@ -604,7 +604,7 @@ int fr_socket_wait_for_connect(int sockfd, fr_time_delta_t timeout) } if (FD_ISSET(sockfd, &error_set)) { - fr_strerror_printf("Failed connecting socket: Unknown error"); + fr_strerror_const("Failed connecting socket: Unknown error"); return -1; } } @@ -650,7 +650,7 @@ int fr_socket_server_udp(fr_ipaddr_t const *src_ipaddr, uint16_t *src_port, char * Check IP looks OK */ if (!src_ipaddr || ((src_ipaddr->af != AF_INET) && (src_ipaddr->af != AF_INET6))) { - fr_strerror_printf("No address specified"); + fr_strerror_const("No address specified"); return -1; } @@ -752,7 +752,7 @@ int fr_socket_server_tcp(fr_ipaddr_t const *src_ipaddr, uint16_t *src_port, char * Check IP looks OK */ if (!src_ipaddr || ((src_ipaddr->af != AF_INET) && (src_ipaddr->af != AF_INET6))) { - fr_strerror_printf("No address specified"); + fr_strerror_const("No address specified"); return -1; } diff --git a/src/lib/util/strerror.c b/src/lib/util/strerror.c index 2f050b8fb82..e79a95bd4c7 100644 --- a/src/lib/util/strerror.c +++ b/src/lib/util/strerror.c @@ -35,9 +35,9 @@ RCSID("$Id$") typedef struct fr_log_entry_s fr_log_entry_t; struct fr_log_entry_s { fr_dlist_t list; - char *msg; //!< Log message. + char const *msg; //!< Log message. - char *subject; //!< Subject for error markers. + char const *subject; //!< Subject for error markers. size_t offset; //!< Where to place the msg marker relative to the subject. }; @@ -386,7 +386,7 @@ void fr_strerror_marker_printf_push_head(char const *subject, size_t offset, cha * * @hidecallergraph */ -static fr_log_entry_t *strerror_const(char const *msg) +static inline CC_HINT(always_inline) fr_log_entry_t *strerror_const(char const *msg) { fr_log_entry_t *entry; fr_log_buffer_t *buffer; @@ -402,12 +402,14 @@ static fr_log_entry_t *strerror_const(char const *msg) return NULL; } - entry = talloc_zero(pool_alternate(buffer), fr_log_entry_t); + entry = talloc(pool_alternate(buffer), fr_log_entry_t); if (!entry) { fr_perror("Failed allocating memory for libradius error buffer"); return NULL; } - memcpy(&entry->msg, &msg, sizeof(entry->msg)); + *entry = (fr_log_entry_t) { + .msg = msg + }; pool_free_alt(buffer); fr_strerror_clear(buffer, false); @@ -452,7 +454,7 @@ static fr_log_entry_t *strerror_const_push(fr_log_buffer_t *buffer, char const * fr_perror("Failed allocating memory for libradius error buffer"); return NULL; } - memcpy(&entry->msg, &msg, sizeof(entry->msg)); + entry->msg = msg; return entry; } diff --git a/src/lib/util/struct.c b/src/lib/util/struct.c index e4d97404216..d5985370231 100644 --- a/src/lib/util/struct.c +++ b/src/lib/util/struct.c @@ -183,7 +183,7 @@ ssize_t fr_struct_from_network(TALLOC_CTX *ctx, fr_cursor_t *cursor, fr_assert(!key_vp); if (!decode_tlv) { - fr_strerror_printf("Decoding TLVs requires a decode_tlv() function to be passed"); + fr_strerror_const("Decoding TLVs requires a decode_tlv() function to be passed"); return -(p - data); } @@ -563,7 +563,7 @@ ssize_t fr_struct_to_network(fr_dbuff_t *dbuff, break; default: - fr_strerror_printf("Invalid bit field"); + fr_strerror_const("Invalid bit field"); return -1; } @@ -584,7 +584,7 @@ ssize_t fr_struct_to_network(fr_dbuff_t *dbuff, /* Not a bit field; insist that no buffered bits remain. */ if (offset != 0) { leftover_bits: - fr_strerror_printf("leftover bits"); + fr_strerror_const("leftover bits"); return -1; } @@ -692,7 +692,7 @@ done: if (do_length) { uint32_t len = fr_dbuff_used(&work_dbuff) - 2; if (len > 65535) { - fr_strerror_printf("Structure size is too large for 16-bit length field."); + fr_strerror_const("Structure size is too large for 16-bit length field."); return -1; } fr_dbuff_in(&hdr_dbuff, (uint16_t)len); diff --git a/src/lib/util/talloc.c b/src/lib/util/talloc.c index 6299df74562..07871e805a9 100644 --- a/src/lib/util/talloc.c +++ b/src/lib/util/talloc.c @@ -92,14 +92,14 @@ fr_talloc_destructor_t *talloc_destructor_add(TALLOC_CTX *fire_ctx, TALLOC_CTX * fr_talloc_destructor_t *d; if (!fire_ctx) { - fr_strerror_printf("No firing ctx provided when setting destructor"); + fr_strerror_const("No firing ctx provided when setting destructor"); return NULL; } d = talloc(fire_ctx, fr_talloc_destructor_t); if (!d) { oom: - fr_strerror_printf("Out of Memory"); + fr_strerror_const("Out of Memory"); return NULL; } @@ -199,7 +199,7 @@ TALLOC_CTX *talloc_aligned_array(TALLOC_CTX *ctx, void **start, size_t alignment array_size = rounded + alignment; array = talloc_array(ctx, uint8_t, array_size); /* Over allocate */ if (!array) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return NULL; } @@ -242,13 +242,13 @@ TALLOC_CTX *talloc_page_aligned_pool(TALLOC_CTX *ctx, void **start, void **end, pool_size = rounded + page_size; pool = talloc_pool(ctx, pool_size); /* Over allocate */ if (!pool) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return NULL; } chunk = talloc_size(pool, 1); /* Get the starting address */ if (!fr_cond_assert((chunk > pool) && ((uintptr_t)chunk < ((uintptr_t)pool + rounded)))) { - fr_strerror_printf("Initial allocation outside of pool memory"); + fr_strerror_const("Initial allocation outside of pool memory"); error: talloc_free(pool); return NULL; @@ -276,7 +276,7 @@ TALLOC_CTX *talloc_page_aligned_pool(TALLOC_CTX *ctx, void **start, void **end, padding = talloc_size(pool, pad_size); if (!fr_cond_assert(((uintptr_t)padding + (uintptr_t)pad_size) >= (uintptr_t)next)) { - fr_strerror_printf("Failed padding pool memory"); + fr_strerror_const("Failed padding pool memory"); goto error; } } diff --git a/src/lib/util/time.c b/src/lib/util/time.c index 8e08e951bd8..52d1d9e4a41 100644 --- a/src/lib/util/time.c +++ b/src/lib/util/time.c @@ -401,7 +401,7 @@ int fr_time_delta_from_str(fr_time_delta_t *out, char const *in, fr_time_res_t h */ while ((*p >= '0') && (*p <= '9')) { if (len > 9) { - fr_strerror_printf("Too much precision for time_delta"); + fr_strerror_const("Too much precision for time_delta"); } sec *= 10; diff --git a/src/lib/util/timeval.c b/src/lib/util/timeval.c index 4fff66c1f0e..7e1e674ee5f 100644 --- a/src/lib/util/timeval.c +++ b/src/lib/util/timeval.c @@ -82,7 +82,7 @@ int fr_timeval_from_str(struct timeval *out, char const *in) len = strlen(end + 1); if (len > 6) { - fr_strerror_printf("Too much precision for timeval"); + fr_strerror_const("Too much precision for timeval"); return -1; } diff --git a/src/lib/util/token.c b/src/lib/util/token.c index b0360fe5cbd..e870d37a0b6 100644 --- a/src/lib/util/token.c +++ b/src/lib/util/token.c @@ -366,7 +366,7 @@ static fr_token_t getthing(char const **ptr, char *buf, int buflen, bool tok, * There's nothing after the backslash, it's an error. */ if (!p[1]) { - fr_strerror_printf("Unterminated string"); + fr_strerror_const("Unterminated string"); return T_INVALID; } @@ -404,7 +404,7 @@ static fr_token_t getthing(char const **ptr, char *buf, int buflen, bool tok, p++; } else { if (buflen < 2) { - fr_strerror_printf("Truncated input"); + fr_strerror_const("Truncated input"); return T_INVALID; } @@ -417,7 +417,7 @@ static fr_token_t getthing(char const **ptr, char *buf, int buflen, bool tok, *s++ = 0; if (quote) { - fr_strerror_printf("Unterminated string"); + fr_strerror_const("Unterminated string"); return T_INVALID; } @@ -458,7 +458,7 @@ fr_token_t getop(char const **ptr) token = getthing(ptr, op, sizeof(op), true, fr_tokens_table, fr_tokens_table_len, false); if (!fr_assignment_op[token] && !fr_equality_op[token]) { - fr_strerror_printf("Expected operator"); + fr_strerror_const("Expected operator"); return T_INVALID; } return token; @@ -520,6 +520,6 @@ ssize_t fr_skip_string(char const *start, char const *end) /* * Unexpected end of string. */ - fr_strerror_printf("Unexpected end of string"); + fr_strerror_const("Unexpected end of string"); return -(p - start); } diff --git a/src/lib/util/trie.c b/src/lib/util/trie.c index 0b663cdd2b3..49e89544d61 100644 --- a/src/lib/util/trie.c +++ b/src/lib/util/trie.c @@ -541,7 +541,7 @@ static fr_trie_node_t *fr_trie_node_alloc(TALLOC_CTX *ctx, int bits) node = (fr_trie_node_t *) talloc_zero_array(ctx, uint8_t, sizeof(fr_trie_node_t) + sizeof(node->trie[0]) * size); if (!node) { - fr_strerror_printf("failed allocating node trie"); + fr_strerror_const("failed allocating node trie"); return NULL; } @@ -620,7 +620,7 @@ static fr_trie_user_t *fr_trie_user_alloc(TALLOC_CTX *ctx, void const *data) user = talloc_zero(ctx, fr_trie_user_t); if (!user) { - fr_strerror_printf("failed allocating user trie"); + fr_strerror_const("failed allocating user trie"); return NULL; } @@ -671,7 +671,7 @@ static fr_trie_path_t *fr_trie_path_alloc(TALLOC_CTX *ctx, uint8_t const *key, i path = talloc_zero(ctx, fr_trie_path_t); if (!path) { - fr_strerror_printf("failed allocating path trie"); + fr_strerror_const("failed allocating path trie"); return NULL; } @@ -714,7 +714,7 @@ static fr_trie_comp_t *fr_trie_comp_alloc(TALLOC_CTX *ctx, int bits) comp = talloc_zero(ctx, fr_trie_comp_t); if (!comp) { - fr_strerror_printf("failed allocating comp trie"); + fr_strerror_const("failed allocating comp trie"); return NULL; } @@ -1496,7 +1496,7 @@ static int fr_trie_path_insert(TALLOC_CTX *ctx, fr_trie_t **trie_p, uint8_t cons * This should have been caught above. */ if (lcp == path->bits) { - fr_strerror_printf("found lcp which should have been previously found"); + fr_strerror_const("found lcp which should have been previously found"); return -1; } @@ -1893,7 +1893,7 @@ int fr_trie_insert(fr_trie_t *ft, void const *key, size_t keylen, void const *da * place without worry. */ if (fr_trie_key_match(user->trie, key, 0, keylen, true) != NULL) { - fr_strerror_printf("Cannot insert due to pre-existing key"); + fr_strerror_const("Cannot insert due to pre-existing key"); return -1; } @@ -2294,7 +2294,7 @@ static int fr_trie_user_verify(fr_trie_t *trie) fr_trie_user_t *user = (fr_trie_user_t *) trie; if (!user->data) { - fr_strerror_printf("user node has no user data"); + fr_strerror_const("user node has no user data"); return -1; } @@ -2350,7 +2350,7 @@ static int fr_trie_path_verify(fr_trie_t *trie) } if (!path->trie) { - fr_strerror_printf("path node has no child trie"); + fr_strerror_const("path node has no child trie"); return -1; } diff --git a/src/lib/util/udp.c b/src/lib/util/udp.c index 4a01d1e0256..ef4e4065f6b 100644 --- a/src/lib/util/udp.c +++ b/src/lib/util/udp.c @@ -189,11 +189,11 @@ ssize_t udp_recv(int sockfd, int flags, if (slen <= 0) goto done; if (fr_ipaddr_from_sockaddr(&socket_out->inet.src_ipaddr, &socket_out->inet.src_port, &src, sizeof_src) < 0) { - fr_strerror_printf_push("Failed converting src sockaddr to ipaddr"); + fr_strerror_const_push("Failed converting src sockaddr to ipaddr"); return -1; } if (fr_ipaddr_from_sockaddr(&socket_out->inet.dst_ipaddr, &socket_out->inet.dst_port, &dst, sizeof_dst) < 0) { - fr_strerror_printf_push("Failed converting dst sockaddr to ipaddr"); + fr_strerror_const_push("Failed converting dst sockaddr to ipaddr"); return -1; } diff --git a/src/lib/util/value.c b/src/lib/util/value.c index e20c8ddffe7..e7ad5f3062f 100644 --- a/src/lib/util/value.c +++ b/src/lib/util/value.c @@ -791,7 +791,7 @@ int fr_value_box_cmp_op(fr_token_t op, fr_value_box_t const *a, fr_value_box_t c b->vb_ip.prefix, (uint8_t const *) &b->vb_ip.addr.v4.s_addr); default: - fr_strerror_printf("Cannot compare IPv4 with IPv6 address"); + fr_strerror_const("Cannot compare IPv4 with IPv6 address"); return -1; } @@ -808,7 +808,7 @@ int fr_value_box_cmp_op(fr_token_t op, fr_value_box_t const *a, fr_value_box_t c b->vb_ip.prefix, (uint8_t const *) &b->vb_ip.addr.v4.s_addr); default: - fr_strerror_printf("Cannot compare IPv4 with IPv6 address"); + fr_strerror_const("Cannot compare IPv4 with IPv6 address"); return -1; } @@ -822,7 +822,7 @@ int fr_value_box_cmp_op(fr_token_t op, fr_value_box_t const *a, fr_value_box_t c b->vb_ip.prefix, (uint8_t const *) &b->vb_ip.addr.v6); default: - fr_strerror_printf("Cannot compare IPv6 with IPv4 address"); + fr_strerror_const("Cannot compare IPv6 with IPv4 address"); return -1; } @@ -839,7 +839,7 @@ int fr_value_box_cmp_op(fr_token_t op, fr_value_box_t const *a, fr_value_box_t c b->vb_ip.prefix, (uint8_t const *) &b->vb_ip.addr.v6); default: - fr_strerror_printf("Cannot compare IPv6 with IPv4 address"); + fr_strerror_const("Cannot compare IPv6 with IPv4 address"); return -1; } @@ -3180,7 +3180,7 @@ int fr_value_box_copy(TALLOC_CTX *ctx, fr_value_box_t *dst, const fr_value_box_t */ str = talloc_bstrndup(ctx, src->vb_strvalue, src->vb_length); if (!str) { - fr_strerror_printf("Failed allocating string buffer"); + fr_strerror_const("Failed allocating string buffer"); return -1; } dst->vb_strvalue = str; @@ -3194,7 +3194,7 @@ int fr_value_box_copy(TALLOC_CTX *ctx, fr_value_box_t *dst, const fr_value_box_t if (src->vb_length) { bin = talloc_memdup(ctx, src->vb_octets, src->vb_length); if (!bin) { - fr_strerror_printf("Failed allocating octets buffer"); + fr_strerror_const("Failed allocating octets buffer"); return -1; } talloc_set_type(bin, uint8_t); @@ -3258,7 +3258,7 @@ int fr_value_box_steal(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t cons str = talloc_steal(ctx, src->vb_strvalue); if (!str) { - fr_strerror_printf("Failed stealing string buffer"); + fr_strerror_const("Failed stealing string buffer"); return -1; } talloc_set_type(str, char); @@ -3273,7 +3273,7 @@ int fr_value_box_steal(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t cons bin = talloc_steal(ctx, src->vb_octets); if (!bin) { - fr_strerror_printf("Failed stealing octets buffer"); + fr_strerror_const("Failed stealing octets buffer"); return -1; } talloc_set_type(bin, uint8_t); @@ -3303,7 +3303,7 @@ int fr_value_box_strdup(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t con str = talloc_typed_strdup(ctx, src); if (!str) { - fr_strerror_printf("Failed allocating string buffer"); + fr_strerror_const("Failed allocating string buffer"); return -1; } @@ -3335,7 +3335,7 @@ int fr_value_box_strtrim(TALLOC_CTX *ctx, fr_value_box_t *vb) memcpy(&mutable, &vb->vb_strvalue, sizeof(mutable)); str = talloc_realloc(ctx, mutable, char, len + 1); if (!str) { - fr_strerror_printf("Failed re-allocing string buffer"); + fr_strerror_const("Failed re-allocing string buffer"); return -1; } vb->vb_length = len; @@ -3433,7 +3433,7 @@ int fr_value_box_bstr_alloc(TALLOC_CTX *ctx, char **out, fr_value_box_t *dst, fr str = talloc_zero_array(ctx, char, len + 1); if (!str) { - fr_strerror_printf("Failed allocating string buffer"); + fr_strerror_const("Failed allocating string buffer"); return -1; } str[len] = '\0'; @@ -3510,7 +3510,7 @@ int fr_value_box_bstrndup(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t c str = talloc_bstrndup(ctx, src, len); if (!str) { - fr_strerror_printf("Failed allocating string buffer"); + fr_strerror_const("Failed allocating string buffer"); return -1; } @@ -3545,7 +3545,7 @@ int fr_value_box_bstrdup_buffer(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_at len = talloc_array_length(src); if ((len == 0) || (src[len - 1] != '\0')) { - fr_strerror_printf("Input buffer not \\0 terminated"); + fr_strerror_const("Input buffer not \\0 terminated"); return -1; } @@ -3590,7 +3590,7 @@ int fr_value_box_bstrdup_buffer_shallow(TALLOC_CTX *ctx, fr_value_box_t *dst, fr len = talloc_array_length(src); if ((len == 0) || (src[len - 1] != '\0')) { - fr_strerror_printf("Input buffer not \\0 terminated"); + fr_strerror_const("Input buffer not \\0 terminated"); return -1; } @@ -3673,7 +3673,7 @@ int fr_value_box_bstr_append_buffer(TALLOC_CTX *ctx, fr_value_box_t *dst, char c len = talloc_array_length(src); if ((len == 0) || (src[len - 1] != '\0')) { - fr_strerror_printf("Input buffer not \\0 terminated"); + fr_strerror_const("Input buffer not \\0 terminated"); return -1; } @@ -3706,7 +3706,7 @@ int fr_value_box_mem_alloc(TALLOC_CTX *ctx, uint8_t **out, fr_value_box_t *dst, bin = talloc_array(ctx, uint8_t, len); if (!bin) { - fr_strerror_printf("Failed allocating octets buffer"); + fr_strerror_const("Failed allocating octets buffer"); return -1; } talloc_set_type(bin, uint8_t); @@ -3788,7 +3788,7 @@ int fr_value_box_memdup(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t con bin = talloc_memdup(ctx, src, len); if (!bin) { - fr_strerror_printf("Failed allocating octets buffer"); + fr_strerror_const("Failed allocating octets buffer"); return -1; } talloc_set_type(bin, uint8_t); @@ -4220,7 +4220,7 @@ parse: p = talloc_array(ctx, uint8_t, ret); if (fr_hex2bin(NULL, &FR_DBUFF_TMP(p, ret), &FR_SBUFF_IN(in + 2, len), false) != (ssize_t)ret) { talloc_free(p); - fr_strerror_printf("Invalid hex data"); + fr_strerror_const("Invalid hex data"); return -1; } @@ -4295,7 +4295,7 @@ parse: */ if (inlen > 0) { if (len >= sizeof(buffer)) { - fr_strerror_printf("Temporary buffer too small"); + fr_strerror_const("Temporary buffer too small"); return -1; } @@ -4809,7 +4809,7 @@ int fr_value_box_list_concat(TALLOC_CTX *ctx, fr_value_box_t const *vb; if (!list || !*list) { - fr_strerror_printf("Invalid arguments. List was NULL"); + fr_strerror_const("Invalid arguments. List was NULL"); return -1; } diff --git a/src/modules/proto_control/proto_control_unix.c b/src/modules/proto_control/proto_control_unix.c index a7998c6ea98..9fa8aed0a08 100644 --- a/src/modules/proto_control/proto_control_unix.c +++ b/src/modules/proto_control/proto_control_unix.c @@ -397,13 +397,13 @@ static int fr_server_domain_socket_peercred(char const *path, uid_t UNUSED uid, struct stat buf; if (!path) { - fr_strerror_printf("No path provided, was NULL"); + fr_strerror_const("No path provided, was NULL"); return -1; } len = strlen(path); if (len >= sizeof(salocal.sun_path)) { - fr_strerror_printf("Path too long in socket filename"); + fr_strerror_const("Path too long in socket filename"); return -1; } @@ -628,7 +628,7 @@ static int fr_server_domain_socket_perm(char const *path, uid_t uid, gid_t gid) p = strrchr(dir, FR_DIR_SEP); if (!p) { - fr_strerror_printf("Failed determining parent directory"); + fr_strerror_const("Failed determining parent directory"); error: talloc_free(dir); if (sock_fd >= 0) close(sock_fd); @@ -773,7 +773,7 @@ static int fr_server_domain_socket_perm(char const *path, uid_t uid, gid_t gid) name = strrchr(path, FR_DIR_SEP); if (!name) { - fr_strerror_printf("Can't determine socket name"); + fr_strerror_const("Can't determine socket name"); goto error; } name++; @@ -829,7 +829,7 @@ static int fr_server_domain_socket_perm(char const *path, uid_t uid, gid_t gid) len = strlen(path); #endif if (len >= sizeof(salocal.sun_path)) { - fr_strerror_printf("Path too long in socket filename"); + fr_strerror_const("Path too long in socket filename"); goto error; } diff --git a/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c b/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c index 73dba98e713..2d5f617fd35 100644 --- a/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c +++ b/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c @@ -237,7 +237,7 @@ do_value: * is malformed. Fail. */ if (flags & FR_DIAMETER_AVP_FLAG_MANDATORY) { - fr_strerror_printf("Mandatory bit is set and attribute is malformed"); + fr_strerror_const("Mandatory bit is set and attribute is malformed"); talloc_free(vp); goto error; } @@ -276,7 +276,7 @@ do_value: char label[] = "ttls challenge"; if ((vp->vp_length < 8) || (vp->vp_length > 16)) { - fr_strerror_printf("Tunneled challenge has invalid length"); + fr_strerror_const("Tunneled challenge has invalid length"); goto error; } @@ -287,7 +287,7 @@ do_value: } if (memcmp(challenge, vp->vp_octets, vp->vp_length) != 0) { - fr_strerror_printf("Tunneled challenge is incorrect"); + fr_strerror_const("Tunneled challenge is incorrect"); goto error; } } diff --git a/src/modules/rlm_icmp/rlm_icmp.c b/src/modules/rlm_icmp/rlm_icmp.c index c5619d6fa34..78a94466e4a 100644 --- a/src/modules/rlm_icmp/rlm_icmp.c +++ b/src/modules/rlm_icmp/rlm_icmp.c @@ -451,7 +451,7 @@ static int mod_thread_instantiate(UNUSED CONF_SECTION const *cs, void *instance, switch (af) { default: - fr_strerror_printf("Unsupported address family"); + fr_strerror_const("Unsupported address family"); return -1; case AF_UNSPEC: @@ -522,7 +522,7 @@ static int mod_thread_instantiate(UNUSED CONF_SECTION const *cs, void *instance, NULL, mod_icmp_error, t) < 0) { - fr_strerror_printf_push("Failed adding socket to event loop"); + fr_strerror_const_push("Failed adding socket to event loop"); close(fd); return -1; } diff --git a/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c b/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c index 57dc9915a33..e18e111b7d6 100644 --- a/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c +++ b/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c @@ -300,7 +300,7 @@ static int read_string(rlm_isc_dhcp_tokenizer_t *state) while (true) { if (!*p) { - fr_strerror_printf("unterminated string"); + fr_strerror_const("unterminated string"); return -1; } @@ -313,7 +313,7 @@ static int read_string(rlm_isc_dhcp_tokenizer_t *state) } if ((size_t) (q - state->string) >= sizeof(state->string)) { - fr_strerror_printf("string is too long"); + fr_strerror_const("string is too long"); return -1; } @@ -355,7 +355,7 @@ redo: if (ret == 0) { if (!state->allow_eof) { - fr_strerror_printf("Unexpected EOF"); + fr_strerror_const("Unexpected EOF"); return -1; } @@ -398,7 +398,7 @@ redo: */ if (*p == ';') { if (semicolon == NO_SEMICOLON) { - fr_strerror_printf("unexpected ';'"); + fr_strerror_const("unexpected ';'"); return -1; } @@ -458,12 +458,12 @@ redo: state->token_len = p - state->token; if (state->token_len == 0) { - fr_strerror_printf("FUCK"); + fr_strerror_const("FUCK"); return -1; } if (state->token_len >= 256) { - fr_strerror_printf("token too large"); + fr_strerror_const("token too large"); return -1; } @@ -473,12 +473,12 @@ redo: */ if (hint == T_LCBRACE) { if (*state->token != '{') { - fr_strerror_printf("missing '{'"); + fr_strerror_const("missing '{'"); return -1; } if ((size_t) state->braces >= (sizeof(spaces) - 1)) { - fr_strerror_printf("sections are nested too deep"); + fr_strerror_const("sections are nested too deep"); return -1; } @@ -488,7 +488,7 @@ redo: if (hint == T_RCBRACE) { if (*state->token != '}') { - fr_strerror_printf("missing '}'"); + fr_strerror_const("missing '}'"); return -1; } @@ -503,7 +503,7 @@ redo: */ if (*state->token == '}') { if (!allow_rcbrace) { - fr_strerror_printf("unexpected '}'"); + fr_strerror_const("unexpected '}'"); return -1; } @@ -517,7 +517,7 @@ redo: */ if ((hint == T_BARE_WORD) || (hint == T_DOUBLE_QUOTED_STRING)) { if (*state->token == '{') { - fr_strerror_printf("unexpected '{'"); + fr_strerror_const("unexpected '{'"); return -1; } } @@ -809,7 +809,7 @@ static int parse_option_space(UNUSED rlm_isc_dhcp_info_t *parent, UNUSED rlm_isc { // @todo - register the named option space with inst->option_space // and create inst->option_space - fr_strerror_printf("please implement 'option space name [ [ code width number ] [ length width number ] [ hash size number ] ]'"); + fr_strerror_const("please implement 'option space name [ [ code width number ] [ length width number ] [ hash size number ] ]'"); return -1; } @@ -860,14 +860,14 @@ static int parse_option_definition(rlm_isc_dhcp_info_t *parent, rlm_isc_dhcp_tok p = strchr(name, '.'); if (p) { - fr_strerror_printf("cannot (yet) define options in spaces"); + fr_strerror_const("cannot (yet) define options in spaces"); error: talloc_free(name); return -1; } if (parent != state->inst->head) { - fr_strerror_printf("option definitions cannot be scoped"); + fr_strerror_const("option definitions cannot be scoped"); goto error; } @@ -934,7 +934,7 @@ static int parse_option_definition(rlm_isc_dhcp_info_t *parent, rlm_isc_dhcp_tok } if ((state->token_len == 1) && (state->token[0] == '{')) { - fr_strerror_printf("records are not supported in option definition"); + fr_strerror_const("records are not supported in option definition"); goto error; } @@ -945,7 +945,7 @@ static int parse_option_definition(rlm_isc_dhcp_info_t *parent, rlm_isc_dhcp_tok * not a *semicolon* error. */ if (!state->saw_semicolon) { - fr_strerror_printf("expected ';'"); + fr_strerror_const("expected ';'"); goto error; } @@ -1097,7 +1097,7 @@ static int parse_options(rlm_isc_dhcp_info_t *parent, rlm_isc_dhcp_tokenizer_t * * Must have at least two arguments. */ if (argc < 2) { - fr_strerror_printf("unexpected ';'"); + fr_strerror_const("unexpected ';'"); return -1; } @@ -1317,13 +1317,13 @@ static int match_keyword(rlm_isc_dhcp_info_t *parent, rlm_isc_dhcp_tokenizer_t * */ if ((semicolon == NO_SEMICOLON) && state->saw_semicolon) { unexpected: - fr_strerror_printf("unexpected ';'"); + fr_strerror_const("unexpected ';'"); talloc_free(info); return -1; } if ((semicolon == YES_SEMICOLON) && !state->saw_semicolon) { - fr_strerror_printf("missing ';'"); + fr_strerror_const("missing ';'"); talloc_free(info); return -1; } @@ -1395,7 +1395,7 @@ static int parse_host(rlm_isc_dhcp_tokenizer_t *state, rlm_isc_dhcp_info_t *info for (child = info->child; child != NULL; child = child->next) { if (child->cmd->type == ISC_HARDWARE_ETHERNET) { if (ether) { - fr_strerror_printf("cannot have two 'hardware ethernet' entries in a 'host'"); + fr_strerror_const("cannot have two 'hardware ethernet' entries in a 'host'"); return -1; } @@ -1687,7 +1687,7 @@ static int add_option_by_da(rlm_isc_dhcp_info_t *info, fr_dict_attr_t const *da) static int parse_filename(UNUSED rlm_isc_dhcp_tokenizer_t *state, rlm_isc_dhcp_info_t *info) { if (info->argv[0]->vb_length > member_size(dhcp_packet_t, file)) { - fr_strerror_printf("filename is too long"); + fr_strerror_const("filename is too long"); return -1; } @@ -1700,7 +1700,7 @@ static int parse_filename(UNUSED rlm_isc_dhcp_tokenizer_t *state, rlm_isc_dhcp_i static int parse_server_name(UNUSED rlm_isc_dhcp_tokenizer_t *state, rlm_isc_dhcp_info_t *info) { if (info->argv[0]->vb_length > member_size(dhcp_packet_t, sname)) { - fr_strerror_printf("filename is too long"); + fr_strerror_const("filename is too long"); return -1; } diff --git a/src/modules/rlm_radius/track.c b/src/modules/rlm_radius/track.c index 8b1dfeb9d92..b1a390c0bd0 100644 --- a/src/modules/rlm_radius/track.c +++ b/src/modules/rlm_radius/track.c @@ -143,7 +143,7 @@ retry: * Request Authenticator. Oh well... */ if (!tt->use_authenticator) { - fr_strerror_printf("No free entries"); + fr_strerror_const("No free entries"); return -1; } diff --git a/src/protocols/arp/base.c b/src/protocols/arp/base.c index 355a8147f24..704cec0cb5a 100644 --- a/src/protocols/arp/base.c +++ b/src/protocols/arp/base.c @@ -107,7 +107,7 @@ int fr_arp_entry_add(int fd, char const *interface, uint8_t ipaddr[static 4], ui struct arpreq req; if (!interface) { - fr_strerror_printf("No interface specified. Cannot update ARP table"); + fr_strerror_const("No interface specified. Cannot update ARP table"); return -1; } @@ -132,7 +132,7 @@ int fr_arp_entry_add(int fd, char const *interface, uint8_t ipaddr[static 4], ui int fr_arp_entry_add(UNUSED int fd, UNUSED char const *interface, UNUSED uint8_t ipaddr[static 4], UNUSED uint8_t macaddr[static 6]) { - fr_strerror_printf("Adding ARP entry is unsupported on this system"); + fr_strerror_const("Adding ARP entry is unsupported on this system"); return -1; } #endif @@ -151,7 +151,7 @@ ssize_t fr_arp_encode(fr_dbuff_t *dbuff, uint8_t const *original, fr_pair_list_t fr_dbuff_t work_dbuff = FR_DBUFF_NO_ADVANCE(dbuff); if (!*vps) { - fr_strerror_printf("Cannot encode empty packet"); + fr_strerror_const("Cannot encode empty packet"); return -1; } @@ -169,7 +169,7 @@ ssize_t fr_arp_encode(fr_dbuff_t *dbuff, uint8_t const *original, fr_pair_list_t * that they don't care about. */ if (!vp) { - fr_strerror_printf("No ARP attributes in the attribute list"); + fr_strerror_const("No ARP attributes in the attribute list"); return -1; } @@ -235,22 +235,22 @@ ssize_t fr_arp_decode(TALLOC_CTX *ctx, uint8_t const *packet, size_t packet_len, */ arp = (fr_arp_packet_t const *) packet; if ((arp->htype[0] != 0) || (arp->htype[1] != 1)) { - fr_strerror_printf("Hardware-Format != Ethernet"); + fr_strerror_const("Hardware-Format != Ethernet"); return -1; } if ((arp->ptype[0] != 8) || (arp->ptype[1] != 0)) { - fr_strerror_printf("Protocol-Format != IPv4"); + fr_strerror_const("Protocol-Format != IPv4"); return -1; } if (arp->hlen != 6) { - fr_strerror_printf("Hardware-Length != 6"); + fr_strerror_const("Hardware-Length != 6"); return -1; } if (arp->plen != 4) { - fr_strerror_printf("Protocol-Length != 4"); + fr_strerror_const("Protocol-Length != 4"); return -1; } diff --git a/src/protocols/dhcpv4/base.c b/src/protocols/dhcpv4/base.c index 2a19ed7ccfa..79551362d7c 100644 --- a/src/protocols/dhcpv4/base.c +++ b/src/protocols/dhcpv4/base.c @@ -243,13 +243,13 @@ bool fr_dhcpv4_ok(uint8_t const *data, ssize_t data_len, uint8_t *message_type, memcpy(&magic, data + 236, 4); magic = ntohl(magic); if (magic != DHCP_OPTION_MAGIC_NUMBER) { - fr_strerror_printf("BOOTP not supported"); + fr_strerror_const("BOOTP not supported"); return false; } code = fr_dhcpv4_packet_get_option((dhcp_packet_t const *) data, data_len, attr_dhcp_message_type); if (!code || (code[1] == 0)) { - fr_strerror_printf("No message-type option was found in the packet"); + fr_strerror_const("No message-type option was found in the packet"); return false; } @@ -667,7 +667,7 @@ static bool attr_valid(UNUSED fr_dict_t *dict, UNUSED fr_dict_attr_t const *pare if (flags->extra || !flags->subtype) return true; if (type != FR_TYPE_STRING) { - fr_strerror_printf("The 'dns_label' flag can only be used with attributes of type 'string'"); + fr_strerror_const("The 'dns_label' flag can only be used with attributes of type 'string'"); return false; } diff --git a/src/protocols/dhcpv4/decode.c b/src/protocols/dhcpv4/decode.c index 600720d5e3c..96bf9e469b9 100644 --- a/src/protocols/dhcpv4/decode.c +++ b/src/protocols/dhcpv4/decode.c @@ -386,7 +386,7 @@ static ssize_t decode_value(TALLOC_CTX *ctx, fr_cursor_t *cursor, len = decode_value_internal(ctx, cursor, parent, p, value_len); if (len <= 0) return len; if (len != (ssize_t)value_len) { - fr_strerror_printf("Failed decoding complete option value"); + fr_strerror_const("Failed decoding complete option value"); return -1; } p += len; diff --git a/src/protocols/dhcpv4/packet.c b/src/protocols/dhcpv4/packet.c index bc2df6be416..38ff870d2be 100644 --- a/src/protocols/dhcpv4/packet.c +++ b/src/protocols/dhcpv4/packet.c @@ -126,7 +126,7 @@ int fr_dhcpv4_decode(TALLOC_CTX *ctx, uint8_t const *data, size_t data_len, fr_c for (i = 0; i < 14; i++) { vp = fr_pair_afrom_da(ctx, *dhcp_header_attrs[i]); if (!vp) { - fr_strerror_printf_push("Cannot decode packet due to internal error"); + fr_strerror_const_push("Cannot decode packet due to internal error"); error: talloc_free(vp); fr_cursor_head(cursor); @@ -368,7 +368,7 @@ int fr_dhcpv4_decode(TALLOC_CTX *ctx, uint8_t const *data, size_t data_len, fr_c mtu = fr_pair_find_by_da(&head, attr_dhcp_interface_mtu_size); if (mtu && (mtu->vp_uint16 < DEFAULT_PACKET_SIZE)) { - fr_strerror_printf("Client says MTU is smaller than minimum permitted by the specification"); + fr_strerror_const("Client says MTU is smaller than minimum permitted by the specification"); return -1; } @@ -433,7 +433,7 @@ fr_radius_packet_t *fr_dhcpv4_packet_alloc(uint8_t const *data, ssize_t data_len /* Now that checks are done, allocate packet */ packet = fr_radius_alloc(NULL, false); if (!packet) { - fr_strerror_printf("Failed allocating packet"); + fr_strerror_const("Failed allocating packet"); return NULL; } diff --git a/src/protocols/dhcpv4/pcap.c b/src/protocols/dhcpv4/pcap.c index ad514a2abdd..46a08e77e43 100644 --- a/src/protocols/dhcpv4/pcap.c +++ b/src/protocols/dhcpv4/pcap.c @@ -133,7 +133,7 @@ fr_radius_packet_t *fr_dhcpv4_pcap_recv(fr_pcap_t *pcap) ret = pcap_next_ex(pcap->handle, &header, &data); if (ret == 0) { - fr_strerror_printf("No packet received from libpcap"); + fr_strerror_const("No packet received from libpcap"); return NULL; /* no packet */ } if (ret < 0) { @@ -143,7 +143,7 @@ fr_radius_packet_t *fr_dhcpv4_pcap_recv(fr_pcap_t *pcap) link_len = fr_pcap_link_layer_offset(data, header->caplen, pcap->link_layer); if (link_len < 0) { - fr_strerror_printf_push("Failed determining link layer header offset"); + fr_strerror_const_push("Failed determining link layer header offset"); return NULL; } @@ -161,7 +161,7 @@ fr_radius_packet_t *fr_dhcpv4_pcap_recv(fr_pcap_t *pcap) break; case 6: - fr_strerror_printf("IPv6 packets not supported by DHCPv4"); + fr_strerror_const("IPv6 packets not supported by DHCPv4"); return NULL; default: diff --git a/src/protocols/dhcpv4/raw.c b/src/protocols/dhcpv4/raw.c index 55eaff003ee..d5e92718983 100644 --- a/src/protocols/dhcpv4/raw.c +++ b/src/protocols/dhcpv4/raw.c @@ -191,13 +191,13 @@ fr_radius_packet_t *fr_dhcv4_raw_packet_recv(int sockfd, struct sockaddr_ll *lin packet = fr_radius_alloc(NULL, false); if (!packet) { - fr_strerror_printf("Failed allocating packet"); + fr_strerror_const("Failed allocating packet"); return NULL; } raw_packet = talloc_zero_array(packet, uint8_t, MAX_PACKET_SIZE); if (!raw_packet) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); fr_radius_packet_free(&packet); return NULL; } @@ -297,13 +297,13 @@ fr_radius_packet_t *fr_dhcv4_raw_packet_recv(int sockfd, struct sockaddr_ll *lin code = fr_dhcpv4_packet_get_option((dhcp_packet_t const *) packet->data, packet->data_len, attr_dhcp_message_type); if (!code) { - fr_strerror_printf("No message-type option was found in the packet"); + fr_strerror_const("No message-type option was found in the packet"); fr_radius_packet_free(&packet); return NULL; } if ((code[1] < 1) || (code[2] == 0) || (code[2] > 8)) { - fr_strerror_printf("Unknown value for message-type option"); + fr_strerror_const("Unknown value for message-type option"); fr_radius_packet_free(&packet); return NULL; } diff --git a/src/protocols/dhcpv4/udp.c b/src/protocols/dhcpv4/udp.c index eaf4089aeaf..2c9db5a8715 100644 --- a/src/protocols/dhcpv4/udp.c +++ b/src/protocols/dhcpv4/udp.c @@ -62,7 +62,7 @@ int fr_dhcpv4_udp_packet_send(fr_radius_packet_t *packet) fr_ipaddr_to_sockaddr(&src, &sizeof_src, &packet->socket.inet.src_ipaddr, packet->socket.inet.src_port); fr_ipaddr_to_sockaddr(&dst, &sizeof_dst, &packet->socket.inet.dst_ipaddr, packet->socket.inet.dst_port); if (packet->data_len == 0) { - fr_strerror_printf("No data to send"); + fr_strerror_const("No data to send"); return -1; } @@ -100,7 +100,7 @@ fr_radius_packet_t *fr_dhcpv4_udp_packet_recv(int sockfd) data = talloc_zero_array(NULL, uint8_t, MAX_PACKET_SIZE); if (!data) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return NULL; } diff --git a/src/protocols/dhcpv6/base.c b/src/protocols/dhcpv6/base.c index d09216fbbfc..0568b5fc8ba 100644 --- a/src/protocols/dhcpv6/base.c +++ b/src/protocols/dhcpv6/base.c @@ -341,20 +341,20 @@ static bool verify_to_client(uint8_t const *packet, size_t packet_len, fr_dhcpv6 transaction_id = fr_net_to_uint24(&packet[1]); if (transaction_id != packet_ctx->transaction_id) { fail_tid: - fr_strerror_printf("Transaction ID does not match"); + fr_strerror_const("Transaction ID does not match"); return false; } if (!fr_dhcpv6_option_find(options, end, FR_SERVER_ID)) { fail_sid: - fr_strerror_printf("Packet does not contain a Server-Id option"); + fr_strerror_const("Packet does not contain a Server-Id option"); return false; } option = fr_dhcpv6_option_find(options, end, FR_CLIENT_ID); if (!option) { fail_cid: - fr_strerror_printf("Packet does not contain a Client-Id option"); + fr_strerror_const("Packet does not contain a Client-Id option"); return false; } @@ -363,14 +363,14 @@ static bool verify_to_client(uint8_t const *packet, size_t packet_len, fr_dhcpv6 */ if (!packet_ctx->duid) { fail_duid: - fr_strerror_printf("Packet context does not contain a DUID"); + fr_strerror_const("Packet context does not contain a DUID"); return false; } check_duid: if (!duid_match(option, packet_ctx)) { fail_match: - fr_strerror_printf("DUID in packet does not match our DUID"); + fr_strerror_const("DUID in packet does not match our DUID"); return false; } return true; @@ -405,7 +405,7 @@ static bool verify_to_client(uint8_t const *packet, size_t packet_len, fr_dhcpv6 option = fr_dhcpv6_option_find(options, end, FR_RECONF_MSG); if (!option) { - fr_strerror_printf("Packet does not contain a Reconf-Msg option"); + fr_strerror_const("Packet does not contain a Reconf-Msg option"); return false; } @@ -422,14 +422,14 @@ static bool verify_to_client(uint8_t const *packet, size_t packet_len, fr_dhcpv6 case FR_DHCPV6_RELAY_REPLY: if (packet_len < DHCPV6_RELAY_HDR_LEN) { - fr_strerror_printf("Relay-Reply message is too small"); + fr_strerror_const("Relay-Reply message is too small"); return false; } options += (DHCPV6_RELAY_HDR_LEN - 4); /* we assumed it was a normal packet above */ option = fr_dhcpv6_option_find(options, end, FR_RELAY_MESSAGE); if (!option) { - fr_strerror_printf("Packet does not contain a Relay-Message option"); + fr_strerror_const("Packet does not contain a Relay-Message option"); return false; } return verify_to_client(option + 4, DHCPV6_GET_OPTION_LEN(option), packet_ctx); @@ -458,7 +458,7 @@ static bool verify_to_client(uint8_t const *packet, size_t packet_len, fr_dhcpv6 case FR_PACKET_TYPE_VALUE_DECLINE: case FR_PACKET_TYPE_VALUE_INFORMATION_REQUEST: default: - fr_strerror_printf("Invalid message type sent to client"); + fr_strerror_const("Invalid message type sent to client"); return false; } @@ -479,7 +479,7 @@ static bool verify_from_client(uint8_t const *packet, size_t packet_len, fr_dhcp * Servers MUST have a DUID */ if (!packet_ctx->duid) { - fr_strerror_printf("Packet context does not contain a DUID"); + fr_strerror_const("Packet context does not contain a DUID"); return false; } @@ -489,13 +489,13 @@ static bool verify_from_client(uint8_t const *packet, size_t packet_len, fr_dhcp case FR_PACKET_TYPE_VALUE_REBIND: if (!fr_dhcpv6_option_find(options, end, FR_CLIENT_ID)) { fail_cid: - fr_strerror_printf("Packet does not contain a Client-Id option"); + fr_strerror_const("Packet does not contain a Client-Id option"); return false; } if (!fr_dhcpv6_option_find(options, end, FR_SERVER_ID)) { fail_sid: - fr_strerror_printf("Packet does not contain a Server-Id option"); + fr_strerror_const("Packet does not contain a Server-Id option"); return false; } break; @@ -511,7 +511,7 @@ static bool verify_from_client(uint8_t const *packet, size_t packet_len, fr_dhcp if (!duid_match(option, packet_ctx)) { fail_match: - fr_strerror_printf("DUID in packet does not match our DUID"); + fr_strerror_const("DUID in packet does not match our DUID"); return false; } break; @@ -526,29 +526,29 @@ static bool verify_from_client(uint8_t const *packet, size_t packet_len, fr_dhcp * IA options are forbidden. */ if (fr_dhcpv6_option_find(options, end, FR_IA_NA)) { - fr_strerror_printf("Packet contains an IA-NA option"); + fr_strerror_const("Packet contains an IA-NA option"); return false; } if (fr_dhcpv6_option_find(options, end, FR_IA_TA)) { - fr_strerror_printf("Packet contains an IA-TA option"); + fr_strerror_const("Packet contains an IA-TA option"); return false; } if (fr_dhcpv6_option_find(options, end, FR_IA_ADDR)) { - fr_strerror_printf("Packet contains an IA-Addr option"); + fr_strerror_const("Packet contains an IA-Addr option"); return false; } break; case FR_DHCPV6_RELAY_FORWARD: if (packet_len < DHCPV6_RELAY_HDR_LEN) { - fr_strerror_printf("Relay-Forward message is too small"); + fr_strerror_const("Relay-Forward message is too small"); return false; } options += (DHCPV6_RELAY_HDR_LEN - 4); /* we assumed it was a normal packet above */ option = fr_dhcpv6_option_find(options, end, FR_RELAY_MESSAGE); if (!option) { - fr_strerror_printf("Packet does not contain a Relay-Message option"); + fr_strerror_const("Packet does not contain a Relay-Message option"); return false; } @@ -566,7 +566,7 @@ static bool verify_from_client(uint8_t const *packet, size_t packet_len, fr_dhcp option = fr_dhcpv6_option_find(options, end, FR_LEASE_QUERY); if (!option) { - fr_strerror_printf("Packet does not contain a Lease-Query option"); + fr_strerror_const("Packet does not contain a Lease-Query option"); return false; } break; @@ -575,7 +575,7 @@ static bool verify_from_client(uint8_t const *packet, size_t packet_len, fr_dhcp case FR_PACKET_TYPE_VALUE_REPLY: case FR_PACKET_TYPE_VALUE_RECONFIGURE: default: - fr_strerror_printf("Invalid message type sent to server"); + fr_strerror_const("Invalid message type sent to server"); return false; } return true; @@ -1012,7 +1012,7 @@ static bool attr_valid(UNUSED fr_dict_t *dict, UNUSED fr_dict_attr_t const *pare if (flags->extra || !flags->subtype) return true; if (type != FR_TYPE_STRING) { - fr_strerror_printf("The 'dns_label' flag can only be used with attributes of type 'string'"); + fr_strerror_const("The 'dns_label' flag can only be used with attributes of type 'string'"); return false; } diff --git a/src/protocols/ethernet/ethernet.c b/src/protocols/ethernet/ethernet.c index f4edfaa687a..e74af8e4244 100644 --- a/src/protocols/ethernet/ethernet.c +++ b/src/protocols/ethernet/ethernet.c @@ -124,7 +124,7 @@ static ssize_t fr_ethernet_decode(void *proto_ctx, uint8_t const *data, size_t d break; default: - fr_strerror_printf("Exceeded maximum level of VLAN tag nesting (2)"); + fr_strerror_const("Exceeded maximum level of VLAN tag nesting (2)"); break; } p = ((uint8_t const *)vlan_hdr) + sizeof(ether_hdr->ether_type); diff --git a/src/protocols/radius/abinary.c b/src/protocols/radius/abinary.c index b35ede52c39..9a7ee86a716 100644 --- a/src/protocols/radius/abinary.c +++ b/src/protocols/radius/abinary.c @@ -408,7 +408,7 @@ static int ascend_parse_ipx_net(int argc, char **argv, char const *p; if (argc < 3) { - fr_strerror_printf("Insufficient arguments to parse 'abinary' IPX network type"); + fr_strerror_const("Insufficient arguments to parse 'abinary' IPX network type"); return -1; } @@ -458,7 +458,7 @@ static int ascend_parse_ipx_net(int argc, char **argv, * Can't be too little or too much. */ if (argc != 6) { - fr_strerror_printf("Insufficient arguments to parse 'abinary' IPX network type"); + fr_strerror_const("Insufficient arguments to parse 'abinary' IPX network type"); return -1; } @@ -565,7 +565,7 @@ static int ascend_parse_ipx(int argc, char **argv, ascend_ipx_filter_t *filter) * Must have "net N node M" */ if (argc < 4) { - fr_strerror_printf("Insufficient arguments to parse 'abinary' IPX type"); + fr_strerror_const("Insufficient arguments to parse 'abinary' IPX type"); return -1; } @@ -575,7 +575,7 @@ static int ascend_parse_ipx(int argc, char **argv, ascend_ipx_filter_t *filter) case FILTER_IPX_SRC_IPXNET: if (flags & 0x01) { duplicate: - fr_strerror_printf("Duplicate field when parsing 'abinary' IPX type"); + fr_strerror_const("Duplicate field when parsing 'abinary' IPX type"); return -1; } slen = ascend_parse_ipx_net(argc - 1, argv + 1, @@ -609,7 +609,7 @@ duplicate: * Arguments left over: die. */ if (argc != 0) { - fr_strerror_printf("Too many arguments to 'abinary' IPX filter"); + fr_strerror_const("Too many arguments to 'abinary' IPX filter"); return -1; } @@ -680,7 +680,7 @@ static int ascend_parse_ipaddr(uint32_t *ipaddr, char *str) goto finalize; default: - fr_strerror_printf("Invalid character in IP address"); + fr_strerror_const("Invalid character in IP address"); return -1; } } /* loop over one character */ @@ -1098,7 +1098,7 @@ static int ascend_parse_generic(int argc, char **argv, * We need at least "offset mask value" */ if (argc < 3) { - fr_strerror_printf("Insufficient arguments to parse 'abinary' generic type"); + fr_strerror_const("Insufficient arguments to parse 'abinary' generic type"); return -1; } @@ -1106,7 +1106,7 @@ static int ascend_parse_generic(int argc, char **argv, * No more than optional comparison and "more" */ if (argc > 5) { - fr_strerror_printf("Too many arguments to parse 'abinary' generic type"); + fr_strerror_const("Too many arguments to parse 'abinary' generic type"); return -1; } @@ -1223,7 +1223,7 @@ ssize_t fr_radius_encode_abinary(fr_pair_t const *vp, uint8_t *out, size_t outle argc = fr_dict_str_to_argv(p, argv, 32); if (argc < 3) { - fr_strerror_printf("Insufficient arguments to parse 'abinary' type"); + fr_strerror_const("Insufficient arguments to parse 'abinary' type"); fail: talloc_free(p); return 0; diff --git a/src/protocols/radius/base.c b/src/protocols/radius/base.c index 9a20f6b32f4..3bb0bbedf43 100644 --- a/src/protocols/radius/base.c +++ b/src/protocols/radius/base.c @@ -357,7 +357,7 @@ int fr_radius_sign(uint8_t *packet, uint8_t const *original, } if (packet_len < RADIUS_HEADER_LENGTH) { - fr_strerror_printf("Packet must be encoded before calling fr_radius_sign()"); + fr_strerror_const("Packet must be encoded before calling fr_radius_sign()"); return -1; } @@ -385,7 +385,7 @@ int fr_radius_sign(uint8_t *packet, uint8_t const *original, } if (msg[1] < 18) { - fr_strerror_printf("Message-Authenticator is too small"); + fr_strerror_const("Message-Authenticator is too small"); return -1; } @@ -453,7 +453,7 @@ int fr_radius_sign(uint8_t *packet, uint8_t const *original, case FR_CODE_PROTOCOL_ERROR: if (!original) { need_original: - fr_strerror_printf("Cannot sign response packet without a request packet"); + fr_strerror_const("Cannot sign response packet without a request packet"); return -1; } memcpy(packet + 4, original + 4, RADIUS_AUTH_VECTOR_LENGTH); @@ -810,7 +810,7 @@ int fr_radius_verify(uint8_t *packet, uint8_t const *original, } if (msg[1] < 18) { - fr_strerror_printf("too small Message-Authenticator"); + fr_strerror_const("too small Message-Authenticator"); return -1; } @@ -829,7 +829,7 @@ int fr_radius_verify(uint8_t *packet, uint8_t const *original, */ rcode = fr_radius_sign(packet, original, secret, secret_len); if (rcode < 0) { - fr_strerror_printf_push("Failed calculating correct authenticator"); + fr_strerror_const_push("Failed calculating correct authenticator"); return -1; } @@ -845,7 +845,7 @@ int fr_radius_verify(uint8_t *packet, uint8_t const *original, memcpy(msg + 2, message_authenticator, sizeof(message_authenticator)); memcpy(packet + 4, request_authenticator, sizeof(request_authenticator)); - fr_strerror_printf("invalid Message-Authenticator (shared secret is incorrect)"); + fr_strerror_const("invalid Message-Authenticator (shared secret is incorrect)"); return -1; } @@ -863,9 +863,9 @@ int fr_radius_verify(uint8_t *packet, uint8_t const *original, if (fr_digest_cmp(request_authenticator, packet + 4, sizeof(request_authenticator)) != 0) { memcpy(packet + 4, request_authenticator, sizeof(request_authenticator)); if (original) { - fr_strerror_printf("invalid Response Authenticator (shared secret is incorrect)"); + fr_strerror_const("invalid Response Authenticator (shared secret is incorrect)"); } else { - fr_strerror_printf("invalid Request Authenticator (shared secret is incorrect)"); + fr_strerror_const("invalid Request Authenticator (shared secret is incorrect)"); } return -1; } @@ -946,7 +946,7 @@ ssize_t fr_radius_encode_dbuff(fr_dbuff_t *dbuff, uint8_t const *original, case FR_CODE_DISCONNECT_NAK: case FR_CODE_PROTOCOL_ERROR: if (!original) { - fr_strerror_printf("Cannot encode response without request"); + fr_strerror_const("Cannot encode response without request"); return -1; } memcpy(packet_ctx.vector, original + 4, sizeof(packet_ctx.vector)); @@ -1133,13 +1133,13 @@ static bool attr_valid(UNUSED fr_dict_t *dict, fr_dict_attr_t const *parent, UNUSED char const *name, UNUSED int attr, fr_type_t type, fr_dict_attr_flags_t *flags) { if (flags->array) { - fr_strerror_printf("RADIUS does not support the 'array' flag."); + fr_strerror_const("RADIUS does not support the 'array' flag."); return false; } if (parent->type == FR_TYPE_STRUCT) { if (flag_extended(flags)) { - fr_strerror_printf("Attributes of type 'extended' cannot be used inside of a 'struct'"); + fr_strerror_const("Attributes of type 'extended' cannot be used inside of a 'struct'"); return false; } @@ -1154,7 +1154,7 @@ static bool attr_valid(UNUSED fr_dict_t *dict, fr_dict_attr_t const *parent, * All other flags are invalid inside of a struct. */ if (flags->subtype) { - fr_strerror_printf("Attributes inside of a 'struct' MUST NOT have flags set"); + fr_strerror_const("Attributes inside of a 'struct' MUST NOT have flags set"); return false; } @@ -1167,7 +1167,7 @@ static bool attr_valid(UNUSED fr_dict_t *dict, fr_dict_attr_t const *parent, */ if (flags->extra) { if (flags->subtype != FLAG_HAS_REF) { - fr_strerror_printf("Unsupported extension."); + fr_strerror_const("Unsupported extension."); return false; } @@ -1188,12 +1188,12 @@ static bool attr_valid(UNUSED fr_dict_t *dict, fr_dict_attr_t const *parent, if (flag_concat(flags)) { if (!parent->flags.is_root) { - fr_strerror_printf("Attributes with the 'concat' flag MUST be at the root of the dictionary"); + fr_strerror_const("Attributes with the 'concat' flag MUST be at the root of the dictionary"); return false; } if (type != FR_TYPE_OCTETS) { - fr_strerror_printf("Attributes with the 'concat' flag MUST be of data type 'octets'"); + fr_strerror_const("Attributes with the 'concat' flag MUST be of data type 'octets'"); return false; } @@ -1214,7 +1214,7 @@ static bool attr_valid(UNUSED fr_dict_t *dict, fr_dict_attr_t const *parent, if (!(parent->flags.is_root || ((parent->type == FR_TYPE_VENDOR) && (parent->parent && parent->parent->type == FR_TYPE_VSA)))) { - fr_strerror_printf("The 'has_tag' flag can only be used with RFC and VSA attributes"); + fr_strerror_const("The 'has_tag' flag can only be used with RFC and VSA attributes"); return false; } @@ -1223,12 +1223,12 @@ static bool attr_valid(UNUSED fr_dict_t *dict, fr_dict_attr_t const *parent, if (flag_extended(flags)) { if (type != FR_TYPE_TLV) { - fr_strerror_printf("The 'long' or 'extended' flag can only be used for attributes of type 'tlv'"); + fr_strerror_const("The 'long' or 'extended' flag can only be used for attributes of type 'tlv'"); return false; } if (!parent->flags.is_root) { - fr_strerror_printf("The 'long' flag can only be used for top-level RFC attributes"); + fr_strerror_const("The 'long' flag can only be used for top-level RFC attributes"); return false; } diff --git a/src/protocols/radius/decode.c b/src/protocols/radius/decode.c index 097cedf7acd..50cd67d7049 100644 --- a/src/protocols/radius/decode.c +++ b/src/protocols/radius/decode.c @@ -74,7 +74,7 @@ ssize_t fr_radius_decode_tunnel_password(uint8_t *passwd, size_t *pwlen, * We need at least a salt. */ if (encrypted_len < 2) { - fr_strerror_printf("Tunnel password is too short"); + fr_strerror_const("Tunnel password is too short"); return -1; } @@ -270,7 +270,7 @@ int fr_radius_decode_tlv_ok(uint8_t const *data, size_t length, size_t dv_type, size_t attrlen; if ((data + dv_type + dv_length) > end) { - fr_strerror_printf("Attribute header overflow"); + fr_strerror_const("Attribute header overflow"); return -1; } @@ -279,12 +279,12 @@ int fr_radius_decode_tlv_ok(uint8_t const *data, size_t length, size_t dv_type, if ((data[0] == 0) && (data[1] == 0) && (data[2] == 0) && (data[3] == 0)) { zero: - fr_strerror_printf("Invalid attribute 0"); + fr_strerror_const("Invalid attribute 0"); return -1; } if (data[0] != 0) { - fr_strerror_printf("Invalid attribute > 2^24"); + fr_strerror_const("Invalid attribute > 2^24"); return -1; } break; @@ -301,7 +301,7 @@ int fr_radius_decode_tlv_ok(uint8_t const *data, size_t length, size_t dv_type, break; default: - fr_strerror_printf("Internal sanity check failed"); + fr_strerror_const("Internal sanity check failed"); return -1; } @@ -311,7 +311,7 @@ int fr_radius_decode_tlv_ok(uint8_t const *data, size_t length, size_t dv_type, case 2: if (data[dv_type] != 0) { - fr_strerror_printf("Attribute is longer than 256 octets"); + fr_strerror_const("Attribute is longer than 256 octets"); return -1; } FALL_THROUGH; @@ -321,17 +321,17 @@ int fr_radius_decode_tlv_ok(uint8_t const *data, size_t length, size_t dv_type, default: - fr_strerror_printf("Internal sanity check failed"); + fr_strerror_const("Internal sanity check failed"); return -1; } if (attrlen < (dv_type + dv_length)) { - fr_strerror_printf("Attribute header has invalid length"); + fr_strerror_const("Attribute header has invalid length"); return -1; } if (attrlen > length) { - fr_strerror_printf("Attribute overflows container"); + fr_strerror_const("Attribute overflows container"); return -1; } @@ -1725,7 +1725,7 @@ static ssize_t fr_radius_decode_proto(TALLOC_CTX *ctx, fr_pair_list_t *list, uin */ vp = fr_pair_afrom_da(ctx, attr_packet_type); if (!vp) { - fr_strerror_printf("Failed creating Packet-Type"); + fr_strerror_const("Failed creating Packet-Type"); return -1; } vp->vp_uint32 = data[0]; @@ -1733,7 +1733,7 @@ static ssize_t fr_radius_decode_proto(TALLOC_CTX *ctx, fr_pair_list_t *list, uin vp = fr_pair_afrom_da(ctx, attr_packet_authentication_vector); if (!vp) { - fr_strerror_printf("Failed creating Packet-Authentication-Vector"); + fr_strerror_const("Failed creating Packet-Authentication-Vector"); return -1; } (void) fr_pair_value_memdup(vp, data + 4, 16, true); diff --git a/src/protocols/radius/encode.c b/src/protocols/radius/encode.c index e211954c5c9..518eaa2a903 100644 --- a/src/protocols/radius/encode.c +++ b/src/protocols/radius/encode.c @@ -380,7 +380,7 @@ static ssize_t encode_value(fr_dbuff_t *dbuff, * Catch errors early on. */ if (flag_encrypted(&vp->da->flags) && !packet_ctx) { - fr_strerror_printf("Asked to encrypt attribute, but no packet context provided"); + fr_strerror_const("Asked to encrypt attribute, but no packet context provided"); return PAIR_ENCODE_FATAL_ERROR; } @@ -605,7 +605,7 @@ static ssize_t encode_value(fr_dbuff_t *dbuff, * Only 24bit integers are allowed here */ if (fr_dbuff_current(&value_start)[0] != 0) { - fr_strerror_printf("Integer overflow for tagged uint32 attribute"); + fr_strerror_const("Integer overflow for tagged uint32 attribute"); return PAIR_ENCODE_SKIPPED; } fr_dbuff_current(&value_start)[0] = packet_ctx->tag; @@ -954,7 +954,7 @@ static ssize_t encode_vendor_attr_hdr(fr_dbuff_t *dbuff, dv = da_stack->da[depth++]; if (dv->type != FR_TYPE_VENDOR) { - fr_strerror_printf("Expected Vendor"); + fr_strerror_const("Expected Vendor"); return PAIR_ENCODE_FATAL_ERROR; } @@ -1315,7 +1315,7 @@ ssize_t fr_radius_encode_pair(fr_dbuff_t *dbuff, fr_cursor_t *cursor, void *enco ((vp->da->attr != FR_CHARGEABLE_USER_IDENTITY) && (vp->da->attr != FR_MESSAGE_AUTHENTICATOR))) { fr_cursor_next(cursor); - fr_strerror_printf("Zero length string attributes not allowed"); + fr_strerror_const("Zero length string attributes not allowed"); return PAIR_ENCODE_SKIPPED; } break; diff --git a/src/protocols/radius/list.c b/src/protocols/radius/list.c index afbffb228a0..38c840d9108 100644 --- a/src/protocols/radius/list.c +++ b/src/protocols/radius/list.c @@ -155,13 +155,13 @@ bool fr_packet_list_socket_freeze(fr_packet_list_t *pl, int sockfd) fr_packet_socket_t *ps; if (!pl) { - fr_strerror_printf("Invalid argument"); + fr_strerror_const("Invalid argument"); return false; } ps = fr_socket_find(pl, sockfd); if (!ps) { - fr_strerror_printf("No such socket"); + fr_strerror_const("No such socket"); return false; } @@ -211,12 +211,12 @@ bool fr_packet_list_socket_add(fr_packet_list_t *pl, int sockfd, int proto, fr_packet_socket_t *ps; if (!pl || !dst_ipaddr || (dst_ipaddr->af == AF_UNSPEC)) { - fr_strerror_printf("Invalid argument"); + fr_strerror_const("Invalid argument"); return false; } if (pl->num_sockets >= MAX_SOCKETS) { - fr_strerror_printf("Too many open sockets"); + fr_strerror_const("Too many open sockets"); return false; } @@ -233,7 +233,7 @@ bool fr_packet_list_socket_add(fr_packet_list_t *pl, int sockfd, int proto, } while (i != start); if (!ps) { - fr_strerror_printf("All socket entries are full"); + fr_strerror_const("All socket entries are full"); return false; } @@ -256,7 +256,7 @@ bool fr_packet_list_socket_add(fr_packet_list_t *pl, int sockfd, int proto, } if (fr_ipaddr_from_sockaddr(&ps->socket.inet.src_ipaddr, &ps->socket.inet.src_port, &src, sizeof_src) < 0) { - fr_strerror_printf("Failed to get IP"); + fr_strerror_const("Failed to get IP"); return false; } @@ -433,7 +433,7 @@ bool fr_packet_list_id_alloc(fr_packet_list_t *pl, int proto, if ((request->socket.inet.dst_ipaddr.af == AF_UNSPEC) || (request->socket.inet.dst_port == 0)) { - fr_strerror_printf("No destination address/port specified"); + fr_strerror_const("No destination address/port specified"); return false; } @@ -447,7 +447,7 @@ bool fr_packet_list_id_alloc(fr_packet_list_t *pl, int proto, src_any = fr_ipaddr_is_inaddr_any(&request->socket.inet.src_ipaddr); if (src_any < 0) { - fr_strerror_printf("Can't check src_ipaddr"); + fr_strerror_const("Can't check src_ipaddr"); return false; } @@ -455,7 +455,7 @@ bool fr_packet_list_id_alloc(fr_packet_list_t *pl, int proto, * MUST specify a destination address. */ if (fr_ipaddr_is_inaddr_any(&request->socket.inet.dst_ipaddr) != 0) { - fr_strerror_printf("Must specify a dst_ipaddr"); + fr_strerror_const("Must specify a dst_ipaddr"); return false; } @@ -606,7 +606,7 @@ bool fr_packet_list_id_alloc(fr_packet_list_t *pl, int proto, * Ask the caller to allocate a new ID. */ if (fd < 0) { - fr_strerror_printf("Failed finding socket, caller must allocate a new one"); + fr_strerror_const("Failed finding socket, caller must allocate a new one"); return false; } diff --git a/src/protocols/radius/packet.c b/src/protocols/radius/packet.c index eb28be0c248..ef400ecf6c4 100644 --- a/src/protocols/radius/packet.c +++ b/src/protocols/radius/packet.c @@ -91,7 +91,7 @@ ssize_t fr_radius_packet_encode(fr_radius_packet_t *packet, fr_radius_packet_t c packet->data_len = (size_t) slen; packet->data = talloc_array(packet, uint8_t, packet->data_len); if (!packet->data) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } @@ -374,7 +374,7 @@ fr_radius_packet_t *fr_radius_packet_recv(TALLOC_CTX *ctx, int fd, int flags, ui */ packet = fr_radius_alloc(ctx, false); if (!packet) { - fr_strerror_printf("out of memory"); + fr_strerror_const("out of memory"); return NULL; } diff --git a/src/protocols/radius/tcp.c b/src/protocols/radius/tcp.c index 76b1aea025c..595f161256f 100644 --- a/src/protocols/radius/tcp.c +++ b/src/protocols/radius/tcp.c @@ -91,7 +91,7 @@ int fr_tcp_read_packet(fr_radius_packet_t *packet, uint32_t max_attributes, bool packet_len = (packet->vector[2] << 8) | packet->vector[3]; if (packet_len < RADIUS_HEADER_LENGTH) { - fr_strerror_printf("Discarding packet: Smaller than RFC minimum of 20 bytes"); + fr_strerror_const("Discarding packet: Smaller than RFC minimum of 20 bytes"); return -1; } @@ -99,13 +99,13 @@ int fr_tcp_read_packet(fr_radius_packet_t *packet, uint32_t max_attributes, bool * If the packet is too big, then the socket is bad. */ if (packet_len > MAX_PACKET_LEN) { - fr_strerror_printf("Discarding packet: Larger than RFC limitation of 4096 bytes"); + fr_strerror_const("Discarding packet: Larger than RFC limitation of 4096 bytes"); return -1; } packet->data = talloc_array(packet, uint8_t, packet_len); if (!packet->data) { - fr_strerror_printf("Out of memory"); + fr_strerror_const("Out of memory"); return -1; } diff --git a/src/protocols/tacacs/base.c b/src/protocols/tacacs/base.c index 2502da8db6d..de09b591b89 100644 --- a/src/protocols/tacacs/base.c +++ b/src/protocols/tacacs/base.c @@ -139,13 +139,13 @@ int fr_tacacs_body_xor(fr_tacacs_packet_t const *pkt, uint8_t *body, size_t body if (pkt->hdr.flags & FR_TAC_PLUS_UNENCRYPTED_FLAG) return 0; else { - fr_strerror_printf("Packet is encrypted but no secret for the client is set"); + fr_strerror_const("Packet is encrypted but no secret for the client is set"); return -1; } } if (pkt->hdr.flags & FR_TAC_PLUS_UNENCRYPTED_FLAG) { - fr_strerror_printf("Packet is unencrypted but a secret has been set for the client"); + fr_strerror_const("Packet is unencrypted but a secret has been set for the client"); return -1; } @@ -218,7 +218,7 @@ ssize_t fr_tacacs_length(uint8_t const *buffer, size_t buffer_len) * There's no reason to accept 64K TACACS+ packets. */ if ((buffer[8] != 0) || (buffer[9] != 0)) { - fr_strerror_printf("Packet is too large. Our limit is 64K"); + fr_strerror_const("Packet is too large. Our limit is 64K"); return -1; } diff --git a/src/protocols/tacacs/decode.c b/src/protocols/tacacs/decode.c index 879284fbb49..c5d80eb4656 100644 --- a/src/protocols/tacacs/decode.c +++ b/src/protocols/tacacs/decode.c @@ -101,7 +101,7 @@ static int tacacs_decode_args(TALLOC_CTX *ctx, fr_cursor_t *cursor, fr_dict_attr vp = fr_pair_afrom_da(ctx, da); if (!vp) { - fr_strerror_printf("Out of Memory"); + fr_strerror_const("Out of Memory"); return -1; } @@ -131,7 +131,7 @@ static int tacacs_decode_field(TALLOC_CTX *ctx, fr_cursor_t *cursor, fr_dict_att vp = fr_pair_afrom_da(ctx, da); if (!vp) { - fr_strerror_printf("Out of Memory"); + fr_strerror_const("Out of Memory"); return -1; } @@ -205,7 +205,7 @@ ssize_t fr_tacacs_decode(TALLOC_CTX *ctx, uint8_t const *buffer, size_t buffer_l * which is a bit under 2^18. */ if ((buffer[8] != 0) || (buffer[9] != 0)) { - fr_strerror_printf("Packet is too large. Our limit is 64K"); + fr_strerror_const("Packet is too large. Our limit is 64K"); return -1; } @@ -214,7 +214,7 @@ ssize_t fr_tacacs_decode(TALLOC_CTX *ctx, uint8_t const *buffer, size_t buffer_l * exactly into however many bytes we read. */ if ((buffer + sizeof(pkt->hdr) + ntohl(pkt->hdr.length)) != end) { - fr_strerror_printf("Packet does not exactly fill buffer"); + fr_strerror_const("Packet does not exactly fill buffer"); return -1; } @@ -245,7 +245,7 @@ ssize_t fr_tacacs_decode(TALLOC_CTX *ctx, uint8_t const *buffer, size_t buffer_l size_t length; if (!secret || secret_len < 1) { - fr_strerror_printf("Packet is encrypted, but no secret is set."); + fr_strerror_const("Packet is encrypted, but no secret is set."); return -1; } @@ -256,7 +256,7 @@ ssize_t fr_tacacs_decode(TALLOC_CTX *ctx, uint8_t const *buffer, size_t buffer_l */ decrypted = talloc_memdup(ctx, buffer, buffer_len); if (!decrypted) { - fr_strerror_printf("Out of Memory"); + fr_strerror_const("Out of Memory"); return -1; } @@ -298,7 +298,7 @@ ssize_t fr_tacacs_decode(TALLOC_CTX *ctx, uint8_t const *buffer, size_t buffer_l if ((pkt->hdr.ver.minor == 0) && (pkt->authen.start.authen_type != FR_AUTHENTICATION_TYPE_VALUE_ASCII)) { - fr_strerror_printf("TACACS+ minor version 1 MUST be used for non-ASCII authentication methods"); + fr_strerror_const("TACACS+ minor version 1 MUST be used for non-ASCII authentication methods"); goto fail; } @@ -384,7 +384,7 @@ ssize_t fr_tacacs_decode(TALLOC_CTX *ctx, uint8_t const *buffer, size_t buffer_l */ if (pkt->hdr.ver.minor != 0) { invalid_version: - fr_strerror_printf("Invalid TACACS+ version"); + fr_strerror_const("Invalid TACACS+ version"); goto fail; } @@ -392,7 +392,7 @@ ssize_t fr_tacacs_decode(TALLOC_CTX *ctx, uint8_t const *buffer, size_t buffer_l PACKET_HEADER_CHECK("Authentication Continue"); if (pkt->authen.start.authen_type != FR_AUTHENTICATION_TYPE_VALUE_ASCII) { - fr_strerror_printf("Authentication-Continue packets MUST NOT be used for PAP, CHAP, MS-CHAP"); + fr_strerror_const("Authentication-Continue packets MUST NOT be used for PAP, CHAP, MS-CHAP"); goto fail; } @@ -443,7 +443,7 @@ ssize_t fr_tacacs_decode(TALLOC_CTX *ctx, uint8_t const *buffer, size_t buffer_l } else { unknown_packet: - fr_strerror_printf("Unknown packet type"); + fr_strerror_const("Unknown packet type"); goto fail; } break; diff --git a/src/protocols/tacacs/encode.c b/src/protocols/tacacs/encode.c index ebce15ffb47..6f5a5ce02cb 100644 --- a/src/protocols/tacacs/encode.c +++ b/src/protocols/tacacs/encode.c @@ -138,7 +138,7 @@ ssize_t fr_tacacs_encode(fr_dbuff_t *dbuff, uint8_t const *original_packet, char if (!vps) { error: - fr_strerror_printf("Cannot encode empty packet"); + fr_strerror_const("Cannot encode empty packet"); return -1; } @@ -352,7 +352,7 @@ ssize_t fr_tacacs_encode(fr_dbuff_t *dbuff, uint8_t const *original_packet, char } else { unknown_packet: - fr_strerror_printf("decode: Unknown packet type"); + fr_strerror_const("decode: Unknown packet type"); return -1; } @@ -680,7 +680,7 @@ ssize_t fr_tacacs_encode(fr_dbuff_t *dbuff, uint8_t const *original_packet, char fr_assert(secret_len > 0); if (!secret || secret_len < 1) { - fr_strerror_printf("decode: Packet is supposed to be encrypted, but no secret is set."); + fr_strerror_const("decode: Packet is supposed to be encrypted, but no secret is set."); return -1; } diff --git a/src/protocols/vmps/base.c b/src/protocols/vmps/base.c index 32062d4d718..b0cb43d836a 100644 --- a/src/protocols/vmps/base.c +++ b/src/protocols/vmps/base.c @@ -60,12 +60,12 @@ int fr_vmps_init(void) } if (fr_dict_autoload(libfreeradius_vmps) < 0) { - fr_strerror_printf_push("Failed loading the 'vmps' dictionary"); + fr_strerror_const_push("Failed loading the 'vmps' dictionary"); return -1; } if (fr_dict_attr_autoload(libfreeradius_vmps_dict_attr) < 0) { - fr_strerror_printf("Failed loading the 'vmps' attributes"); + fr_strerror_const("Failed loading the 'vmps' attributes"); fr_dict_autofree(libfreeradius_vmps); return -1; } diff --git a/src/protocols/vmps/vmps.c b/src/protocols/vmps/vmps.c index 06a6cc072d5..f37c45081be 100644 --- a/src/protocols/vmps/vmps.c +++ b/src/protocols/vmps/vmps.c @@ -103,7 +103,7 @@ bool fr_vmps_ok(uint8_t const *packet, size_t *packet_len) while (data_len > 0) { if (data_len < 7) { - fr_strerror_printf("Packet contains malformed attribute"); + fr_strerror_const("Packet contains malformed attribute"); return false; } @@ -113,7 +113,7 @@ bool fr_vmps_ok(uint8_t const *packet, size_t *packet_len) */ if ((ptr[0] != 0) || (ptr[1] != 0) || (ptr[2] != 0x0c) || (ptr[3] < 1) || (ptr[3] > 8)) { - fr_strerror_printf("Packet contains invalid attribute"); + fr_strerror_const("Packet contains invalid attribute"); return false; } @@ -158,7 +158,7 @@ int fr_vmps_decode(TALLOC_CTX *ctx, uint8_t const *data, size_t data_len, fr_cur vp = fr_pair_afrom_da(ctx, attr_packet_type); if (!vp) { oom: - fr_strerror_printf("Out of Memory"); + fr_strerror_const("Out of Memory"); return -1; } vp->vp_uint32 = data[1]; @@ -206,7 +206,7 @@ int fr_vmps_decode(TALLOC_CTX *ctx, uint8_t const *data, size_t data_len, fr_cur * but it doesn't hurt to do it again. */ if (attr_len > (size_t) (end - ptr)) { - fr_strerror_printf("Attribute length exceeds received data"); + fr_strerror_const("Attribute length exceeds received data"); return -1; } @@ -215,7 +215,7 @@ int fr_vmps_decode(TALLOC_CTX *ctx, uint8_t const *data, size_t data_len, fr_cur */ vp = fr_pair_afrom_child_num(ctx, fr_dict_root(dict_vmps), attr); if (!vp) { - fr_strerror_printf("No memory"); + fr_strerror_const("No memory"); return -1; }