代码之家  ›  专栏  ›  技术社区  ›  Simon Duff

rsyslogd re\u匹配导致分段错误

  •  0
  • Simon Duff  · 技术社区  · 5 年前

    当我有规则的时候

    if ($msg contains "foobah"
     OR re_match($msg, '(authmgr|cli)\[[0-9]+\]:')
    )
    then {
    

    rsyslog最后抛出了一个分段错误。甚至当我注释掉包含 re_match 它仍然会抛出一个分段错误。

    rsyslogd 8.24.0-34.el7, compiled with:
            PLATFORM:                               x86_64-redhat-linux-gnu
            PLATFORM (lsb_release -d):
            FEATURE_REGEXP:                         Yes
            GSSAPI Kerberos 5 support:              Yes
            FEATURE_DEBUG (debug build, slow code): No
            32bit Atomic operations supported:      Yes
            64bit Atomic operations supported:      Yes
            memory allocator:                       system default
            Runtime Instrumentation (slow code):    No
            uuid support:                           Yes
            Number of Bits in RainerScript integers: 64
    

    authmgr[123]: cli:[456]:

    有人能确认正则表达式的格式是正确的,并解释为什么注释掉那一行会导致分段错误吗?

    0 回复  |  直到 5 年前
        1
  •  0
  •   meuh    5 年前

    答案似乎是,您需要在字符串中转义反斜杠,因此这应该是可行的:

    re_match($msg, '(authmgr|cli)\\[[0-9]+\\]:')
    

    表达式中的字符“”无效-是否存在无效的转义序列?

    online tool 正确地转义字符串。如果你提供 a\b a\\b .