New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matchattr: false positives or just wrong responses #419

Closed
ghost opened this Issue Jul 6, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@ghost

ghost commented Jul 6, 2017

matchattr &h #ValidChannel returns true when when there are NO local (channel) flags.

<Domino> $$ chattr domino #channel
<Bot> [TCL (0ms)] aefghjlmnoptuvwxyzMN|-
<Domino> $$ matchattr domino &h #channel
<Bot> [TCL (0ms)] 1
<Domino> $$ matchattr domino h #channel
<Bot> [TCL (0ms)] 1
<Domino> $$ matchattr domino h
<Bot> [TCL (0ms)] 1

As you can see below, false-positives are being triggered as such:

b c i [Neither global nor local flag exists, yet, local is showing a match via "&" and "|" (both produce the same results)]

h j p t x [only exists as a global flag, yet, the local flag is showing a match]

<Domino> $$ chattr domino #channel
<Bot> [TCL (0ms)] aefghjlmnoptuvwxyzMN|-

Notice: I have *NO* local-level flags in this example, only global flags.

Here's a loop I did; see the insanity below:

<Domino> $$ foreach a [alphabet -split -lower] { msghomer ${a}:GLOBAL([matchattr domino $a]):LOCAL:&([matchattr domino &$a #channel]):LOCAL:|([matchattr domino |$a #channel]) }
<Bot> a:GLOBAL(1):LOCAL:&(0):LOCAL:|(0)
<Bot> b:GLOBAL(0):LOCAL:&(1):LOCAL:|(1)
<Bot> c:GLOBAL(0):LOCAL:&(1):LOCAL:|(1)
<Bot> d:GLOBAL(0):LOCAL:&(0):LOCAL:|(0)
<Bot> e:GLOBAL(1):LOCAL:&(0):LOCAL:|(0)
<Bot> f:GLOBAL(1):LOCAL:&(0):LOCAL:|(0)
<Bot> g:GLOBAL(1):LOCAL:&(0):LOCAL:|(0)
<Bot> h:GLOBAL(1):LOCAL:&(1):LOCAL:|(1)
<Bot> i:GLOBAL(1):LOCAL:&(1):LOCAL:|(1)
<Bot> j:GLOBAL(1):LOCAL:&(1):LOCAL:|(1)
<Bot> k:GLOBAL(0):LOCAL:&(0):LOCAL:|(0)
<Bot> l:GLOBAL(1):LOCAL:&(0):LOCAL:|(0)
<Bot> m:GLOBAL(1):LOCAL:&(0):LOCAL:|(0)
<Bot> n:GLOBAL(1):LOCAL:&(0):LOCAL:|(0)
<Bot> o:GLOBAL(1):LOCAL:&(0):LOCAL:|(0)
<Bot> p:GLOBAL(1):LOCAL:&(1):LOCAL:|(1)
<Bot> q:GLOBAL(0):LOCAL:&(0):LOCAL:|(0)
<Bot> r:GLOBAL(0):LOCAL:&(0):LOCAL:|(0)
<Bot> s:GLOBAL(1):LOCAL:&(0):LOCAL:|(0)
<Bot> t:GLOBAL(1):LOCAL:&(1):LOCAL:|(1)
<Bot> u:GLOBAL(1):LOCAL:&(0):LOCAL:|(0)
<Bot> v:GLOBAL(1):LOCAL:&(0):LOCAL:|(0)
<Bot> w:GLOBAL(1):LOCAL:&(0):LOCAL:|(0)
<Bot> x:GLOBAL(1):LOCAL:&(1):LOCAL:|(1)
<Bot> y:GLOBAL(1):LOCAL:&(0):LOCAL:|(0)
<Bot> z:GLOBAL(1):LOCAL:&(0):LOCAL:|(0)

I know you hate me.

@thommey thommey self-assigned this Jul 13, 2017

@thommey thommey added this to the v1.8.3 milestone Jul 17, 2017

@vanosg

This comment has been minimized.

Show comment
Hide comment
@vanosg

vanosg Nov 13, 2017

Collaborator

On quick glance, it looks like a matchattr run against a non-channel flag (CHAN_VALID) incorrectly returns a 1- I don't think it has anything to do with matching incorrectly against the global flags.

I'd start looking at line 252 in tcluser.c as a potential culprit, user.match = FR_GLOBAL | (argc == 4 ? FR_CHAN : 0) | FR_BOT; , it seems to force a comparison against global flags? mebbe.

Collaborator

vanosg commented Nov 13, 2017

On quick glance, it looks like a matchattr run against a non-channel flag (CHAN_VALID) incorrectly returns a 1- I don't think it has anything to do with matching incorrectly against the global flags.

I'd start looking at line 252 in tcluser.c as a potential culprit, user.match = FR_GLOBAL | (argc == 4 ? FR_CHAN : 0) | FR_BOT; , it seems to force a comparison against global flags? mebbe.

@vanosg vanosg closed this in #483 Nov 25, 2017

vanosg added a commit that referenced this issue Nov 25, 2017

Fix matchattr for local flags. Fixes #419
* Fix matchattr for local flags
Tcl matchattr command incorrectly returned true when checking against an invalid channel flag. This patch checks first checks if the channel flag is invalid and, if it is, returns false.
* Fix botflag matching and chanflag validating.
* Generate Tcl error on searching for invalid flags
* Reorder internal botflags to only change unused ones.
* Update matchattr docs with better usage examples
@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost commented Jul 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment