Skip to content

fix: reject invalid flag in RegisterQueryFile - #394

Merged
Nord1cWarr1or merged 2 commits into
rehlds:masterfrom
Nord1cWarr1or:fix/rechecker-registerqueryfile-invalid-flag
Sep 24, 2026
Merged

Nord1cWarr1or merged 2 commits into
rehlds:masterfrom
Nord1cWarr1or:fix/rechecker-registerqueryfile-invalid-flag

Conversation

@Nord1cWarr1or

@Nord1cWarr1or Nord1cWarr1or commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

🖤

Purpose

RegisterQueryFile() documents that type "can be only RES_TYPE_EXISTS, RES_TYPE_MISSING or RES_TYPE_HASH_ANY", but RES_TYPE_NONE / RES_TYPE_IGNORE were only logged, not rejected: after AMXX_LogError the break leaves the switch and registration continues, returning a handle that only looks alive. Its forward can never fire — ReChecker invokes the query callback only when query->flag == typeFind, and NONE/IGNORE match no resource-check event. Resolves #393.

Approach

One line. After the error log, return FALSE — consistent with the native's other error paths (empty file argument, public callback not found), which already do:

 	case RES_TYPE_NONE:
 	case RES_TYPE_IGNORE:
 		AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: invalid flag type \"%i\".", __FUNCTION__, flag);
-		break;
+		return FALSE;

Open Questions and Pre-Merge TODOs

  • Module builds cleanly on Linux 32-bit — only the pre-existing harmless DT_TEXTREL ld warning.
  • An invalid flag now returns 0 instead of a dead handle; valid flags (RES_TYPE_EXISTS, RES_TYPE_MISSING, RES_TYPE_HASH_ANY) take the same paths as before.
  • Re-checked statically against the ReChecker 2.7 sources (resource.cpp): the callback fires only on query->flag == typeFind.

Learning

Callback invocation condition traced in ReChecker 2.7 resource.cpp.

Resolves: #393

RES_TYPE_NONE/RES_TYPE_IGNORE only logged an error and fell through to Add(), registering a dead query (ReChecker never fires the callback when query->flag does not match, and NONE/IGNORE never match) while returning a working-looking handle to the plugin. Return FALSE after the error, consistent with the other error paths (empty file, public not found).
@Nord1cWarr1or Nord1cWarr1or changed the title fix: reject invalid ResourceType flag in RegisterQueryFile fix: reject invalid flag in RegisterQueryFile Sep 23, 2026
@TheKrytyk

Copy link
Copy Markdown

@s1lentq Can you add this request to master as well as those others? It’s taking an awfully long time

@Nord1cWarr1or
Nord1cWarr1or merged commit 95089cb into rehlds:master Sep 24, 2026
3 checks passed
@Nord1cWarr1or
Nord1cWarr1or deleted the fix/rechecker-registerqueryfile-invalid-flag branch September 24, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ReChecker] RegisterQueryFile registers a dead query for invalid ResourceType flags (no rejection)

2 participants