* Note that we don't care about the length of the input string,
* because '\0' is an invalid UTF-8 character.
*/
-static int utf8_char(uint8_t *str)
+int fr_utf8_char(const uint8_t *str)
{
if (*str < 0x20) return 0;
*/
void fr_print_string(const char *in, size_t inlen, char *out, size_t outlen)
{
- uint8_t *str = (uint8_t *)in;
+ const uint8_t *str = (const uint8_t *) in;
int sp = 0;
int utf8 = 0;
* Some clients send strings with an off-by-one
* length (confused with strings in C).
*/
- if ((inlen == 0) && (*str == 0)) break;
+ if ((inlen == 1) && (*str == 0)) break;
switch (*str) {
case '\\':
continue;
}
- utf8 = utf8_char((uint8_t *)str);
+ utf8 = fr_utf8_char(str);
if (!utf8) {
snprintf(out, outlen, "\\%03o", *str);
out += 4;
case PW_TYPE_INTEGER:
if ( vp->flags.has_tag ) {
/* Attribute value has a tag, need to ignore it */
- if ((v = dict_valbyattr(vp->attribute, (vp->vp_integer & 0xffffff)))
+ if ((v = dict_valbyattr(vp->attribute, vp->vendor, (vp->vp_integer & 0xffffff)))
!= NULL)
a = v->name;
else {
case PW_TYPE_BYTE:
case PW_TYPE_SHORT:
/* Normal, non-tagged attribute */
- if ((v = dict_valbyattr(vp->attribute, vp->vp_integer))
+ if ((v = dict_valbyattr(vp->attribute, vp->vendor, vp->vp_integer))
!= NULL)
a = v->name;
else {
"<`STRING`>"
};
-const char *vp_print_name(char *buffer, size_t bufsize, int attr)
+const char *vp_print_name(char *buffer, size_t bufsize, int attr, int vendor)
{
- int vendor;
size_t len = 0;
if (!buffer) return NULL;
- vendor = VENDOR(attr);
if (vendor) {
DICT_VENDOR *v;
if (!vp) return 0;
name = vp->name;
- len = 0;
if (!name || !*name) {
- if (!vp_print_name(namebuf, sizeof(namebuf), vp->attribute)) {
+ if (!vp_print_name(namebuf, sizeof(namebuf), vp->attribute, vp->attribute)) {
return 0;
}
name = namebuf;