| radcli_avp_get_cstr(3) | Radius client library | radcli_avp_get_cstr(3) |
NAME
radcli_avp_get_cstr - Read an attribute's value as a NUL-terminated string, with no allocation or copy.
SYNOPSIS
#include <radcli/>
const char * radcli_avp_get_cstr(
const radcli_avp *a
);
DESCRIPTION
Meaningful for RADCLI_TYPE_STRING and RADCLI_TYPE_TEXT attributes, but callable on any type, like radcli_avp_get_bytes() every attribute is stored with a trailing NUL one byte past its real length, so this never allocates. Returns NULL, rather than a silently short string, if the value contains an embedded NUL byte before its real end (logged at LOG_WARNING): a server-supplied value of e.g. "admin attacker" must not be readable back as the trusted string "admin" by any caller that treats this return value as the whole attribute. Use radcli_avp_get_bytes() instead for an attribute where an embedded NUL is expected and meaningful (e.g. one whose dictionary type is not RADCLI_TYPE_STRING or RADCLI_TYPE_TEXT).
For a RADCLI_TYPE_TEXT attribute specifically, this also returns NULL (logged at LOG_WARNING) if the value is not valid UTF-8 (RFC 8044 SS3.1) checked here as well as in radcli_avp_add_str(), since an attribute can also be populated by radcli_avp_decode() from a received packet, whose bytes never went through add-side validation. RADCLI_TYPE_STRING attributes have no such requirement: NUL-checked only, like every other type.
PARAMETERS
- a
- the attribute.
RETURN VALUE
a pointer valid for a's lifetime (owned by the list a came from never freed by the caller), or NULL if a is NULL, its value contains an embedded NUL byte, or (for RADCLI_TYPE_TEXT) its value is not valid UTF-8.
SEE ALSO
radcli_avp_add_bytes(3), radcli_avp_add_bytes_by_num(3), radcli_avp_add_gigawords64(3), radcli_avp_add_gigawords64_by_num(3), radcli_avp_add_ip4(3), radcli_avp_add_ip4_by_num(3), radcli_avp_add_ip4prefix(3), radcli_avp_add_ip4prefix_by_num(3), radcli_avp_add_ip6(3), radcli_avp_add_ip6_by_num(3), radcli_avp_add_str(3), radcli_avp_add_str_by_num(3), radcli_avp_add_uint32(3), radcli_avp_add_uint32_by_num(3), radcli_avp_add_uint64(3), radcli_avp_add_uint64_by_num(3), radcli_avp_add_username(3), radcli_avp_concat_str(3), radcli_avp_concat_str_by_num(3), radcli_avp_def(3), radcli_avp_get(3), radcli_avp_get_by_num(3), radcli_avp_get_bytes(3), radcli_avp_get_bytes_by_num(3), radcli_avp_get_cstr_by_num(3), radcli_avp_get_gigawords64(3), radcli_avp_get_gigawords64_by_num(3), radcli_avp_get_ip4prefix(3), radcli_avp_get_ip4prefix_by_num(3), radcli_avp_get_ip6(3), radcli_avp_get_ip6_by_num(3), radcli_avp_get_uint32(3), radcli_avp_get_uint32_by_num(3), radcli_avp_get_uint64(3), radcli_avp_get_uint64_by_num(3), radcli_avp_iter_next(3), radcli_avp_list_error(3), radcli_avp_list_free(3), radcli_avp_list_iter(3), radcli_avp_list_new(3)
| 2026-09-03 | radcli |