/* Check that the IPv4 address in <test> matches the IP/mask in pattern */
int acl_match_ip(struct sample *smp, struct acl_pattern *pattern);
-/* Executes a regex. It needs to change the data. If it is marked READ_ONLY
- * then it will be allocated and duplicated in place so that others may use
- * it later on. Note that this is embarrassing because we always try to avoid
- * allocating memory at run time.
+/* Executes a regex. It temporarily changes the data to add a trailing zero,
+ * and restores the previous character when leaving.
*/
int acl_match_reg(struct sample *smp, struct acl_pattern *pattern);
SMP_F_VOL_TXN = 1 << 5, /* result sensitive to new transaction (eg: HTTP version) */
SMP_F_VOL_SESS = 1 << 6, /* result sensitive to new session (eg: src IP) */
SMP_F_VOLATILE = (1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6), /* any volatility condition */
-
- SMP_F_READ_ONLY = 1 << 7, /* returned data must not be altered */
- SMP_F_MUST_FREE = 1 << 10, /* migration: this sample must be freed ASAP */
-
};
/* pattern fetch direction */
return node;
}
-/* Executes a regex. It needs to change the data. If it is marked READ_ONLY
- * then it will be allocated and duplicated in place so that others may use
- * it later on. Note that this is embarrassing because we always try to avoid
- * allocating memory at run time.
+/* Executes a regex. It temporarily changes the data to add a trailing zero,
+ * and restores the previous character when leaving.
*/
int acl_match_reg(struct sample *smp, struct acl_pattern *pattern)
{
char old_char;
int ret;
- if (unlikely(smp->flags & SMP_F_READ_ONLY)) {
- char *new_str;
-
- new_str = calloc(1, smp->data.str.len + 1);
- if (!new_str)
- return ACL_PAT_FAIL;
-
- memcpy(new_str, smp->data.str.str, smp->data.str.len);
- new_str[smp->data.str.len] = 0;
- if (smp->flags & SMP_F_MUST_FREE)
- free(smp->data.str.str);
- smp->data.str.str = new_str;
- smp->flags |= SMP_F_MUST_FREE;
- smp->flags &= ~SMP_F_READ_ONLY;
- }
-
old_char = smp->data.str.str[smp->data.str.len];
smp->data.str.str[smp->data.str.len] = 0;
*
*/
- /* now we may have some cleanup to do */
- if (smp.flags & SMP_F_MUST_FREE) {
- free(smp.data.str.str);
- smp.data.str.len = 0;
- }
-
/* we're ORing these terms, so a single PASS is enough */
if (acl_res == ACL_PAT_PASS)
break;
acl_fetch_be_id(struct proxy *px, struct session *l4, void *l7, int dir,
struct acl_expr *expr, struct sample *smp)
{
- smp->flags = SMP_F_READ_ONLY;
smp->flags = SMP_F_VOL_TXN;
smp->type = SMP_T_UINT;
smp->data.uint = l4->be->uuid;
if (!target_srv(&l4->target))
return 0;
- smp->flags = SMP_F_READ_ONLY;
smp->type = SMP_T_UINT;
smp->data.uint = target_srv(&l4->target)->puid;
acl_fetch_fe_id(struct proxy *px, struct session *l4, void *l7, int dir,
struct acl_expr *expr, struct sample *smp)
{
- smp->flags = SMP_F_READ_ONLY;
smp->flags = SMP_F_VOL_SESS;
smp->type = SMP_T_UINT;
smp->data.uint = l4->fe->uuid;
smp->data.str.len = txn->req.sl.rq.m_l;
smp->data.str.str = txn->req.buf->p + txn->req.sol;
}
- smp->flags = SMP_F_READ_ONLY | SMP_F_VOL_1ST;
+ smp->flags = SMP_F_VOL_1ST;
return 1;
}
smp->data.str.str = ptr;
smp->data.str.len = len;
- smp->flags = SMP_F_READ_ONLY | SMP_F_VOL_1ST;
+ smp->flags = SMP_F_VOL_1ST;
return 1;
}
smp->data.str.str = ptr;
smp->data.str.len = len;
- smp->flags = SMP_F_READ_ONLY | SMP_F_VOL_1ST;
+ smp->flags = SMP_F_VOL_1ST;
return 1;
}
if (px->options & PR_O_HTTP_PROXY)
l4->flags |= SN_ADDR_SET;
- smp->flags = SMP_F_READ_ONLY;
+ smp->flags = 0;
return 1;
}
ptr++;
smp->data.str.len = ptr - smp->data.str.str;
-
- /* we do not need to set READ_ONLY because the data is in a buffer */
smp->flags = SMP_F_VOL_1ST;
return 1;
}
acl_fetch_so_id(struct proxy *px, struct session *l4, void *l7, int dir,
struct acl_expr *expr, struct sample *smp)
{
- smp->flags = SMP_F_READ_ONLY;
smp->type = SMP_T_UINT;
smp->data.uint = l4->listener->luid;
return 1;