From a8a742f48c3bb10a5ef5164f211326ae3d8d3837 Mon Sep 17 00:00:00 2001 From: bol-van Date: Mon, 2 Mar 2026 20:21:38 +0300 Subject: [PATCH] zapret-lib: call apply_arg_prefix right before instance execute --- docs/changes.txt | 1 + docs/manual.en.md | 5 ++++- docs/manual.md | 5 ++++- lua/zapret-lib.lua | 4 +++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 6152a62..7d5e822 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -265,3 +265,4 @@ v0.9.4.3 * winws2, dvtws2: ASLR * github, linux-builder: reduce arm executable size by 20% - move to armv7+thumb * init.d: warn if hostlist/ipset files are inside zapret2 root +* zapret-lib: do not call apply_arg_prefix in apply_execution_plan - call it right before instance execute diff --git a/docs/manual.en.md b/docs/manual.en.md index 3511b5f..019e78e 100644 --- a/docs/manual.en.md +++ b/docs/manual.en.md @@ -3531,7 +3531,7 @@ Checks the [instance cutoff](#instance_cutoff) state for `desync.func_instance` function apply_arg_prefix(desync) ``` -Performs substitution of argument values from `desync.arg` that start with `%` and `#`. +Performs substitution of argument values from `desync.arg` that start with `%`, `#`, `\`. ### apply_execution_plan @@ -3540,6 +3540,7 @@ function apply_execution_plan(desync, instance) ``` Copies the instance identification and its arguments from an [execution plan](#execution_plan) `instance` into the desync object, thereby recreating the desync state as if the `instance` were called directly by C code. +With one exception : apply_arg_prefix is not applied because args can refer a blob created by previous conditionally executed instances. The [execution plan](#execution_plan) is provided by the C function `execution_plan()` as an array of `instance` elements. ### verdict_aggregate @@ -3558,6 +3559,7 @@ function plan_instance_execute_preapplied(desync, verdict, instance) ``` Executes an [execution plan](#execution_plan) `instance`, taking into account the [instance cutoff](#instance_cutoff) and standard [payload](#in-profile-filters) and [range](#in-profile-filters) filters. +Calls apply_arg_prefix right before calling the instance. Returns the aggregation of the current verdict and the `instance` verdict. The "preapplied" version does not apply execution plan, allowing the calling code to do so. @@ -4479,6 +4481,7 @@ function cond_lua(desync) ``` Executes a Lua code from the "cond_code" argument. The code returns condition value. Direct addressing of the desync table is possible within the code. +desync.arg is passed without called "apply_arg_prefix" : `%`, `#`, `\` remain as is without substitution because can refer blobs created by previous conditionally executed instances. # Auxiliary programs diff --git a/docs/manual.md b/docs/manual.md index 73264d0..bc86911 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -3709,7 +3709,7 @@ function cutoff_shim_check(desync) function apply_arg_prefix(desync) ``` -Выполняет подстановку значений аргументов из desync.arg, начинающихся с `%` и `#`. +Выполняет подстановку значений аргументов из desync.arg, начинающихся с `%` и `#`, `\`. ### apply_execution_plan @@ -3719,6 +3719,7 @@ function apply_execution_plan(desync, instance) Копирует в desync идентификацию инстанса и его аргументы из элемента [execution plan](#execution_plan) `instance`, тем самым воссоздает состояние desync, как если бы `instance` был вызван напрямую C кодом. +За одним исключением : apply_arg_prefix не применяется, поскольку может содержать несуществующие блоб, существование которого зависит от условного выполнения предыдущих истансов. [execution plan](#execution_plan) выдается C функцией `execution_plan()` как массив, элементами которого являются `instance`. ### verdict_aggregate @@ -3737,6 +3738,7 @@ function plan_instance_execute_preapplied(desync, verdict, instance) ``` Выполняет элемент [execution plan](#execution_plan) `instance` с учетом [instance cutoff](#instance_cutoff) и стандартных фильтров [payload](#внутрипрофильные-фильтры) и [range](#внутрипрофильные-фильтры). +При совпадении условий непосредственно перед вызовом выполняет apply_arg_prefix. Возвращает агрегацию verdict и вердикта `instance`. Вариант "preapplied" не выполняет apply_execution_plan, позволяя это сделат вызывающему коду. @@ -4658,6 +4660,7 @@ function cond_lua(desync) ``` Выполняет Lua код из аргумента "cond_code". Код возвращает значение условия через return. Возможна прямая адресация таблицы desync. +desync.arg передаются с НЕ разименованными `%`, `#`, `\`, поскольку разименование может ссылаться на блобы, создаваемые предыдущими условно вызываемыми инстансами. # Вспомогательные программы diff --git a/lua/zapret-lib.lua b/lua/zapret-lib.lua index 68c7d32..e9949ac 100644 --- a/lua/zapret-lib.lua +++ b/lua/zapret-lib.lua @@ -173,7 +173,7 @@ function apply_execution_plan(desync, instance) desync.func_n = instance.func_n desync.func_instance = instance.func_instance desync.arg = deepcopy(instance.arg) - apply_arg_prefix(desync) + -- no apply_arg_prefix here because it may refer non-existing blobs end -- produce resulting verdict from 2 verdicts function verdict_aggregate(v1, v2) @@ -200,6 +200,8 @@ function plan_instance_execute_preapplied(desync, verdict, instance) elseif not pos_check_range(desync, instance.range) then DLOG("plan_instance_execute: not calling '"..desync.func_instance.."' because pos "..pos_str(desync,instance.range.from).." "..pos_str(desync,instance.range.to).." is out of range '"..pos_range_str(instance.range).."'") else + -- condition is satisfied. here blobs must be referenced + apply_arg_prefix(desync) DLOG("plan_instance_execute: calling '"..desync.func_instance.."'") verdict = verdict_aggregate(verdict,_G[instance.func](nil, desync)) end