When an expression was fixed-up at runtime by the core and the
module had fparam-type fixup, the fparam fixup re-evaluated
the result, e.g.:
$bar=test;
$foo="$bar";
f($foo) => "test" instead of "$bar".
Now all the RVE-enabled fparam fixups will avoid this case.
MODF_RVE_PARAM_FREE(src, dst); \
goto error; \
} \
MODF_RVE_PARAM_FREE(src, dst); \
goto error; \
} \
- (dst)[i+2].type = STRING_ST; \
+ (dst)[i+2].type = STRING_RVE_ST; \
(dst)[i+2].u.string = s.s; \
(dst)[i+2].u.str.len = s.len; \
rval_destroy(rv); \
(dst)[i+2].u.string = s.s; \
(dst)[i+2].u.str.len = s.len; \
rval_destroy(rv); \
LVAL_ST, RVE_ST,
RETCODE_ST, CASE_ST,
BLOCK_ST, JUMPTABLE_ST, CONDTABLE_ST, MATCH_CONDTABLE_ST,
LVAL_ST, RVE_ST,
RETCODE_ST, CASE_ST,
BLOCK_ST, JUMPTABLE_ST, CONDTABLE_ST, MATCH_CONDTABLE_ST,
- FPARAM_DYN_ST /* temporary only */
+ STRING_RVE_ST /* RVE converted to a string (fparam hack) */,
+ FPARAM_DYN_ST /* temporary only (fparam hack) */
};
typedef enum _expr_l_type expr_l_type;
};
typedef enum _expr_l_type expr_l_type;
+
+/** get a pointer to a parameter internal type.
+ * @param param
+ * @return pointer to the parameter internal type.
+ */
+action_param_type* fixup_get_param_ptype(void** param)
+{
+ action_u_t* a;
+ a = (void*)((char*)param - (char*)&(((action_u_t*)(0))->u.string));
+ return &a->type;
+}
+
+
+/** get a parameter internal type.
+ * @see fixup_get_param_ptype().
+ * @return paramter internal type.
+ */
+action_param_type fixup_get_param_type(void** param)
+{
+ return *fixup_get_param_ptype(param);
+}
+
+
+
/* fixes flag params (resolves possible named flags)
* use PARAM_USE_FUNC|PARAM_STRING as a param. type and create
* a wrapper function that does just:
/* fixes flag params (resolves possible named flags)
* use PARAM_USE_FUNC|PARAM_STRING as a param. type and create
* a wrapper function that does just:
+ if (fixup_get_param_type(param) == STRING_RVE_ST &&
+ (types & (FPARAM_INT|FPARAM_STR|FPARAM_STRING))) {
+ /* if called with a RVE already converted to string =>
+ don't try AVP, PVAR or SELECT (to avoid double
+ deref., e.g.: $foo="$bar"; f($foo) ) */
+ types &= ~ (FPARAM_AVP|FPARAM_PVS|FPARAM_SELECT|FPARAM_PVE);
+ }
for (t=types & ~(types-1); types; types&=(types-1), t=types & ~(types-1)){
if ((ret=fix_param(t, param))<=0) return ret;
}
for (t=types & ~(types-1); types; types&=(types-1), t=types & ~(types-1)){
if ((ret=fix_param(t, param))<=0) return ret;
}
int fixup_var_str_12(void** param, int param_no)
{
int ret;
int fixup_var_str_12(void** param, int param_no)
{
int ret;
- if ((sr_cfg_compat!=SR_COMPAT_SER) &&
- ((ret = fix_param(FPARAM_PVS, param)) <= 0)) return ret;
- if ((ret = fix_param(FPARAM_AVP, param)) <= 0) return ret;
- if ((ret = fix_param(FPARAM_SELECT, param)) <= 0) return ret;
+ if (fixup_get_param_type(param) != STRING_RVE_ST) {
+ /* if called with a RVE already converted to string =>
+ don't try AVP, PVAR or SELECT (to avoid double
+ deref., e.g.: $foo="$bar"; f($foo) ) */
+ if ((sr_cfg_compat!=SR_COMPAT_SER) &&
+ ((ret = fix_param(FPARAM_PVS, param)) <= 0)) return ret;
+ if ((ret = fix_param(FPARAM_AVP, param)) <= 0) return ret;
+ if ((ret = fix_param(FPARAM_SELECT, param)) <= 0) return ret;
+ }
if ((ret = fix_param(FPARAM_STR, param)) <= 0) return ret;
ERR("Error while fixing parameter, AVP, SELECT, and str conversions"
" failed\n");
if ((ret = fix_param(FPARAM_STR, param)) <= 0) return ret;
ERR("Error while fixing parameter, AVP, SELECT, and str conversions"
" failed\n");
int fixup_var_int_12(void** param, int param_no)
{
int ret;
int fixup_var_int_12(void** param, int param_no)
{
int ret;
- if ((sr_cfg_compat!=SR_COMPAT_SER) &&
- ((ret = fix_param(FPARAM_PVS, param)) <= 0)) return ret;
- if ((ret = fix_param(FPARAM_AVP, param)) <= 0) return ret;
- if ((ret = fix_param(FPARAM_SELECT, param)) <= 0) return ret;
+ if (fixup_get_param_type(param) != STRING_RVE_ST) {
+ /* if called with a RVE already converted to string =>
+ don't try AVP, PVAR or SELECT (to avoid double
+ deref., e.g.: $foo="$bar"; f($foo) ) */
+ if ((sr_cfg_compat!=SR_COMPAT_SER) &&
+ ((ret = fix_param(FPARAM_PVS, param)) <= 0)) return ret;
+ if ((ret = fix_param(FPARAM_AVP, param)) <= 0) return ret;
+ if ((ret = fix_param(FPARAM_SELECT, param)) <= 0) return ret;
+ }
if ((ret = fix_param(FPARAM_INT, param)) <= 0) return ret;
ERR("Error while fixing parameter, AVP, SELECT, and int conversions"
" failed\n");
if ((ret = fix_param(FPARAM_INT, param)) <= 0) return ret;
ERR("Error while fixing parameter, AVP, SELECT, and int conversions"
" failed\n");