*/
int fr_value_box_from_str(TALLOC_CTX *ctx, fr_value_box_t *dst,
fr_type_t *src_type, fr_dict_attr_t const *src_enumv,
- char const *src, ssize_t src_len, char quote);
+ char const *src, ssize_t src_len, char quote, bool tainted);
/*
* Printing
{
fr_type_t type = da->type; /* Might change - Stupid combo IP */
- if (fr_value_box_from_str(NULL, &value, &type, NULL, argv[2], -1, '\0') < 0) {
+ if (fr_value_box_from_str(NULL, &value, &type, NULL, argv[2], -1, '\0', false) < 0) {
fr_strerror_printf_push("Invalid VALUE for ATTRIBUTE \"%s\"", da->name);
return -1;
}
type = da->type;
if (fr_value_box_from_str(this, &value, &type, NULL,
- this->value, talloc_array_length(this->value) - 1, '\0') < 0) {
+ this->value, talloc_array_length(this->value) - 1, '\0', false) < 0) {
fr_strerror_printf_push("Invalid VALUE for ATTRIBUTE \"%s\"", da->name);
goto error;
}
* We presume that the input data is from a double quoted
* string, and needs escaping
*/
- if (fr_value_box_from_str(vp, &vp->data, &type, vp->da, value, inlen, '"') < 0) return -1;
+ if (fr_value_box_from_str(vp, &vp->data, &type, vp->da, value, inlen, '"', false) < 0) return -1;
/*
* If we parsed to a different type than the DA associated with
case FR_TYPE_STRING:
if (fr_value_box_from_str(ctx, dst, &dst_type, dst_enumv,
- src->datum.strvalue, src->datum.length, '\0') < 0) return -1;
+ src->datum.strvalue, src->datum.length, '\0', false) < 0) return -1;
break;
case FR_TYPE_OCTETS:
case FR_TYPE_STRING:
if (fr_value_box_from_str(ctx, dst, &dst_type, dst_enumv,
- src->datum.strvalue, src->datum.length, '\0') < 0) return -1;
+ src->datum.strvalue, src->datum.length, '\0', false) < 0) return -1;
break;
case FR_TYPE_STRING:
if (fr_value_box_from_str(ctx, dst, &dst_type, dst_enumv,
- src->datum.strvalue, src->datum.length, '\0') < 0) return -1;
+ src->datum.strvalue, src->datum.length, '\0', false) < 0) return -1;
break;
case FR_TYPE_OCTETS:
case FR_TYPE_STRING:
if (fr_value_box_from_str(ctx, dst, &dst_type, dst_enumv,
- src->datum.strvalue, src->datum.length, '\0') < 0) return -1;
+ src->datum.strvalue, src->datum.length, '\0', false) < 0) return -1;
break;
case FR_TYPE_OCTETS:
* Deserialise a fr_value_box_t
*/
if (src->type == FR_TYPE_STRING) return fr_value_box_from_str(ctx, dst, &dst_type, dst_enumv,
- src->datum.strvalue, src->datum.length, '\0');
+ src->datum.strvalue,
+ src->datum.length, '\0', false);
if ((src->type == FR_TYPE_IFID) &&
(dst_type == FR_TYPE_UINT64)) {
* length, else inlen should be the length of the string or
* sub string to parse.
* @param[in] quote character used set unescape mode. @see value_str_unescape.
+ * @param[in] tainted Whether the value came from a trusted source.
* @return
* - 0 on success.
* - -1 on parse error.
*/
int fr_value_box_from_str(TALLOC_CTX *ctx, fr_value_box_t *dst,
fr_type_t *dst_type, fr_dict_attr_t const *dst_enumv,
- char const *in, ssize_t inlen, char quote)
+ char const *in, ssize_t inlen, char quote, bool tainted)
{
size_t len;
ssize_t ret;
finish:
dst->datum.length = ret;
dst->type = *dst_type;
+ dst->tainted = tainted;
/*
* Fixup enumv
*/
if (quote == '/') quote = '\0';
- if (fr_value_box_from_str(ctx, &data, &src_type, NULL, start + 1, p - (start + 1), quote) < 0) {
+ if (fr_value_box_from_str(ctx, &data, &src_type, NULL,
+ start + 1, p - (start + 1), quote, false) < 0) {
*error = "error parsing string";
return -1;
}
parse:
if (do_unescape) {
- if (fr_value_box_from_str(ctx, &data, &data_type, NULL, in, inlen, quote) < 0) return 0;
+ if (fr_value_box_from_str(ctx, &data, &data_type, NULL,
+ in, inlen, quote, false) < 0) return 0;
vpt = tmpl_alloc(ctx, TMPL_TYPE_UNPARSED, data.datum.strvalue,
talloc_array_length(data.datum.strvalue) - 1, type);
*/
if (do_unescape) {
if (fr_value_box_from_str(ctx, &data, &data_type, NULL, in,
- inlen, fr_token_quote[type]) < 0) return -1;
+ inlen, fr_token_quote[type], false) < 0) return -1;
if (do_xlat) {
vpt = tmpl_alloc(ctx, TMPL_TYPE_XLAT, data.datum.strvalue,
talloc_array_length(data.datum.strvalue) - 1, type);
case T_BACK_QUOTED_STRING:
if (do_unescape) {
if (fr_value_box_from_str(ctx, &data, &data_type, NULL, in,
- inlen, fr_token_quote[type]) < 0) return -1;
+ inlen, fr_token_quote[type], false) < 0) return -1;
vpt = tmpl_alloc(ctx, TMPL_TYPE_EXEC, data.datum.strvalue,
talloc_array_length(data.datum.strvalue) - 1, type);
* Why do we pass a pointer to the tmpl type? Goddamn WiMAX.
*/
if (fr_value_box_from_str(vpt, &vpt->tmpl_value_box, &vpt->tmpl_fr_value_box_type,
- enumv, vpt->name, vpt->len, '\0') < 0) return -1;
+ enumv, vpt->name, vpt->len, '\0', false) < 0) return -1;
vpt->type = TMPL_TYPE_DATA;
break;
*
* @fixme We need a way of signalling xlat not to escape things.
*/
- ret = fr_value_box_from_str(tmp_ctx, &tmp, &src_type, NULL, value.datum.strvalue, value.datum.length, '"');
+ ret = fr_value_box_from_str(tmp_ctx, &tmp, &src_type, NULL,
+ value.datum.strvalue, value.datum.length, '"', false);
if (ret < 0) goto error;
value.datum.strvalue = tmp.datum.strvalue;
* @fixme We need a way of signalling xlat not to escape things.
*/
ret = fr_value_box_from_str(tmp_ctx, &tmp, &src_type, NULL,
- value.datum.strvalue, value.datum.length, '"');
+ value.datum.strvalue, value.datum.length, '"', false);
if (ret < 0) goto error;
value.datum.strvalue = tmp.datum.strvalue;
type = FR_TYPE_STRING;
if (fr_value_box_from_str(ctx, &data, &type, NULL, child,
- talloc_array_length(child) - 1, '"') < 0) {
+ talloc_array_length(child) - 1, '"', false) < 0) {
talloc_free(child);
return NULL;
}