Skip to content

Commit

Permalink
radius_parseattr should output errors with fr_strerror_printf (even t…
Browse files Browse the repository at this point in the history
…hough it's not a library function)
  • Loading branch information
arr2036 committed Mar 16, 2014
1 parent dae25ca commit e1d09ca
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 0 additions & 2 deletions src/include/libradius.h
Expand Up @@ -591,13 +591,11 @@ VALUE_PAIR *readvp2(TALLOC_CTX *ctx, FILE *fp, bool *pfiledone, char const *errp
/*
* Error functions.
*/
#ifdef _LIBRADIUS
void fr_strerror_printf(char const *, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 1, 2)))
#endif
;
#endif
void fr_perror(char const *, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 1, 2)))
Expand Down
9 changes: 5 additions & 4 deletions src/main/map.c
Expand Up @@ -76,15 +76,15 @@ int radius_parse_attr(value_pair_tmpl_t *vpt, char const *name, request_refs_t r
vpt->request = radius_request_name(&p, request_def);
len = p - name;
if (vpt->request == REQUEST_UNKNOWN) {
ERROR("Invalid request qualifier \"%.*s\"", (int) len, name);
fr_strerror_printf("Invalid request qualifier \"%.*s\"", (int) len, name);
return -1;
}
name += len;

vpt->list = radius_list_name(&p, list_def);
if (vpt->list == PAIR_LIST_UNKNOWN) {
len = p - name;
ERROR("Invalid list qualifier \"%.*s\"", (int) len, name);
fr_strerror_printf("Invalid list qualifier \"%.*s\"", (int) len, name);
return -1;
}

Expand All @@ -97,7 +97,7 @@ int radius_parse_attr(value_pair_tmpl_t *vpt, char const *name, request_refs_t r
if (!da) {
da = dict_attrunknownbyname(p, false);
if (!da) {
ERROR("Unknown attribute \"%s\"", p);
fr_strerror_printf("Unknown attribute \"%s\"", p);
return -1;
}
}
Expand Down Expand Up @@ -131,6 +131,7 @@ value_pair_tmpl_t *radius_attr2tmpl(TALLOC_CTX *ctx, char const *name,
copy = talloc_strdup(vpt, name);

if (radius_parse_attr(vpt, copy, request_def, list_def) < 0) {
ERROR("%s", fr_strerror());
radius_tmplfree(&vpt);
return NULL;
}
Expand Down Expand Up @@ -233,7 +234,7 @@ value_pair_tmpl_t *radius_str2tmpl(TALLOC_CTX *ctx, char const *name, FR_TOKEN t
}


/** Convert strings to value_pair_map_e
/** Convert strings to value_pair_map_t
*
* Treatment of operands depends on quotation, barewords are treated
* as attribute references, double quoted values are treated as
Expand Down
4 changes: 3 additions & 1 deletion src/main/modcall.c
Expand Up @@ -2536,18 +2536,20 @@ static bool pass2_callback(UNUSED void *ctx, fr_cond_t *c)
value_pair_map_t *old;
value_pair_tmpl_t vpt;

old = c->data.map;

/*
* It's still not an attribute. Ignore it.
*/
if (radius_parse_attr(&vpt, map->dst->name, REQUEST_CURRENT, PAIR_LIST_REQUEST) < 0) {
cf_log_err(old->ci, "Failed parsing condition: %s", fr_strerror());
c->pass2_fixup = PASS2_FIXUP_NONE;
return true;
}

/*
* Re-parse the LHS as an attribute.
*/
old = c->data.map;
map = radius_str2map(c, old->dst->name, T_BARE_WORD, old->op,
old->src->name, T_BARE_WORD,
REQUEST_CURRENT, PAIR_LIST_REQUEST,
Expand Down
1 change: 1 addition & 0 deletions src/main/valuepair.c
Expand Up @@ -1440,6 +1440,7 @@ int radius_get_vp(VALUE_PAIR **vp_p, REQUEST *request, char const *name)
*vp_p = NULL;

if (radius_parse_attr(&vpt, name, REQUEST_CURRENT, PAIR_LIST_REQUEST) < 0) {
RDEBUG("%s", fr_strerror());
return -1;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/xlat.c
Expand Up @@ -316,6 +316,7 @@ static ssize_t xlat_debug_attr(UNUSED void *instance, REQUEST *request, char con
if (*fmt == '&') fmt++;

if (radius_parse_attr(&vpt, fmt, REQUEST_CURRENT, PAIR_LIST_REQUEST) < 0) {
RDEBUG("%s", fr_strerror());
return -1;
}

Expand Down

0 comments on commit e1d09ca

Please sign in to comment.