radcli_avp_get_cstr3
Read an attribute's value as a nul-terminated string, with no allocation or copy.
Usage
#include <radcli/>
const char * radcli_avp_get_cstr(
const radcli_avp *a
);
Overview
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.