Skip to content

Commit b7c4f2a

Browse files
committed
transformations: Fix edge-cases with {param.value} and {uri.param}
For inputs containing only the parameter part, these transformations would return a bogus {NULL, 0} value (flagged as PV_VAL_STR), which cannot be used in assignments or conditional checks: Credits to Bogdan-Andrei Iancu for finding this issue!
1 parent 0fb0094 commit b7c4f2a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

str.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ typedef struct __str_const str_const;
6969
/* str initialization */
7070
#define STR_NULL ((str){NULL, 0})
7171
#define STR_NULL_const ((str_const){NULL, 0})
72+
#define STR_EMPTY ((str){"", 0})
73+
#define STR_EMPTY_const ((str_const){"", 0})
7274
#define str_init(_string) ((str){_string, sizeof(_string) - 1})
7375
#define str_const_init(_string) ((str_const){_string, sizeof(_string) - 1})
7476

transformations.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,10 @@ int tr_eval_uri(struct sip_msg *msg, tr_param_t *tp, int subtype,
12041204
if (pit->name.len==sv.len
12051205
&& strncasecmp(pit->name.s, sv.s, sv.len)==0)
12061206
{
1207-
val->rs = pit->body;
1207+
if (ZSTR(pit->body))
1208+
val->rs = STR_EMPTY;
1209+
else
1210+
val->rs = pit->body;
12081211
goto done;
12091212
}
12101213
}
@@ -2226,7 +2229,10 @@ int tr_eval_paramlist(struct sip_msg *msg, tr_param_t *tp, int subtype,
22262229
if (pit->name.len==sv.len
22272230
&& strncasecmp(pit->name.s, sv.s, sv.len)==0)
22282231
{
2229-
val->rs = pit->body;
2232+
if (ZSTR(pit->body))
2233+
val->rs = STR_EMPTY;
2234+
else
2235+
val->rs = pit->body;
22302236
goto done;
22312237
}
22322238
}

0 commit comments

Comments
 (0)