#
86e9c9aa |
| 20-Jun-2023 |
Jeremy Sowden <jeremy@azazel.net> |
lib/ts_bm: add helper to reduce indentation and improve readability
The flow-control of `bm_find` is very deeply nested with a conditional comparing a ternary expression against the pattern inside a
lib/ts_bm: add helper to reduce indentation and improve readability
The flow-control of `bm_find` is very deeply nested with a conditional comparing a ternary expression against the pattern inside a for-loop inside a while-loop inside a for-loop.
Move the inner for-loop into a helper function to reduce the amount of indentation and make the code easier to read.
Fix indentation and trailing white-space in preceding debug logging statement.
Signed-off-by: Jeremy Sowden <jeremy@azazel.net> Signed-off-by: Florian Westphal <fw@strlen.de>
show more ...
|
#
6f67fbf8 |
| 19-Jun-2023 |
Jeremy Sowden <jeremy@azazel.net> |
lib/ts_bm: reset initial match offset for every block of text
The `shift` variable which indicates the offset in the string at which to start matching the pattern is initialized to `bm->patlen - 1`,
lib/ts_bm: reset initial match offset for every block of text
The `shift` variable which indicates the offset in the string at which to start matching the pattern is initialized to `bm->patlen - 1`, but it is not reset when a new block is retrieved. This means the implemen- tation may start looking at later and later positions in each successive block and miss occurrences of the pattern at the beginning. E.g., consider a HTTP packet held in a non-linear skb, where the HTTP request line occurs in the second block:
[... 52 bytes of packet headers ...] GET /bmtest HTTP/1.1\r\nHost: www.example.com\r\n\r\n
and the pattern is "GET /bmtest".
Once the first block comprising the packet headers has been examined, `shift` will be pointing to somewhere near the end of the block, and so when the second block is examined the request line at the beginning will be missed.
Reinitialize the variable for each new block.
Fixes: 8082e4ed0a61 ("[LIB]: Boyer-Moore extension for textsearch infrastructure strike #2") Link: https://bugzilla.netfilter.org/show_bug.cgi?id=1390 Signed-off-by: Jeremy Sowden <jeremy@azazel.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
show more ...
|
#
4a70ce5f |
| 04-Jul-2022 |
Colin Ian King <colin.i.king@gmail.com> |
lib/ts_bm.c: remove redundant store to variable consumed after addition
There is no need to store the result of the addition back to variable consumed after the addition. The store is redundant, re
lib/ts_bm.c: remove redundant store to variable consumed after addition
There is no need to store the result of the addition back to variable consumed after the addition. The store is redundant, replace += with just +
Cleans up clang scan build warning: lib/ts_bm.c:83:11: warning: Although the value stored to 'consumed' is used in the enclosing expression, the value is never actually read from 'consumed' [deadcode.DeadStores]
Link: https://lkml.kernel.org/r/20220704215325.600993-1-colin.i.king@gmail.com Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
show more ...
|
#
d89775fc |
| 12-Aug-2020 |
Alexander A. Klimov <grandmaster@al2klimov.de> |
lib/: replace HTTP links with HTTPS ones
Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate.
Signed-off-by: Alexander A. Klimo
lib/: replace HTTP links with HTTPS ones
Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate.
Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Coly Li <colyli@suse.de> [crc64.c] Link: http://lkml.kernel.org/r/20200726112154.16510-1-grandmaster@al2klimov.de Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
show more ...
|
#
c6e2ac3b |
| 07-Apr-2020 |
Gustavo A. R. Silva <gustavo@embeddedor.com> |
lib/ts_bm.c: replace zero-length array with flexible-array member
The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to decla
lib/ts_bm.c: replace zero-length array with flexible-array member
The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member[1][2], introduced in C99:
struct foo { int stuff; struct boo array[]; };
By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being inadvertenly introduced[3] to the codebase from now on.
This issue was found with the help of Coccinelle.
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html [2] https://github.com/KSPP/linux/issues/21 [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Link: http://lkml.kernel.org/r/20200211205620.GA24694@embeddedor Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
show more ...
|
#
2874c5fd |
| 27-May-2019 |
Thomas Gleixner <tglx@linutronix.de> |
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152
Based on 1 normalized pattern(s):
this program is free software you can redistribute it and or modify it under the terms of th
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152
Based on 1 normalized pattern(s):
this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version
extracted by the scancode license scanner the SPDX license identifier
GPL-2.0-or-later
has been chosen to replace the boilerplate/reference in 3029 file(s).
Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
#
3b76d081 |
| 08-Jul-2008 |
Joonwoo Park <joonwpark81@gmail.com> |
textsearch: ts_bm: support case insensitive searching in Boyer-Moore algorithm
Add support for case insensitive search to Boyer-Moore algorithm.
Signed-off-by: Joonwoo Park <joonwpark81@gmail.com>
textsearch: ts_bm: support case insensitive searching in Boyer-Moore algorithm
Add support for case insensitive search to Boyer-Moore algorithm.
Signed-off-by: Joonwoo Park <joonwpark81@gmail.com> Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
show more ...
|
#
aebb6a84 |
| 30-Jun-2008 |
Joonwoo Park <joonwpark81@gmail.com> |
textsearch: fix Boyer-Moore text search bug
The current logic has a bug which cannot find matching pattern, if the pattern is matched from the first character of target string. for example: pattern
textsearch: fix Boyer-Moore text search bug
The current logic has a bug which cannot find matching pattern, if the pattern is matched from the first character of target string. for example: pattern=abc, string=abcdefg pattern=a, string=abcdefg Searching algorithm should return 0 for those things.
Signed-off-by: Joonwoo Park <joonwpark81@gmail.com> Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
show more ...
|
#
3ffaa8c7 |
| 22-Aug-2006 |
Michael Rash <mbr@cipherdyne.org> |
[TEXTSEARCH]: Fix Boyer Moore initialization bug
The pattern is set after trying to compute the prefix table, which tries to use it. Initialize it before calling compute_prefix_tbl, make compute_pre
[TEXTSEARCH]: Fix Boyer Moore initialization bug
The pattern is set after trying to compute the prefix table, which tries to use it. Initialize it before calling compute_prefix_tbl, make compute_prefix_tbl consistently use only the data from struct ts_bm and remove the now unnecessary arguments.
Signed-off-by: Michael Rash <mbr@cipherdyne.org> Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
show more ...
|
#
6ab3d562 |
| 30-Jun-2006 |
Jörn Engel <joern@wohnheim.fh-wedel.de> |
Remove obsolete #include <linux/config.h>
Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de> Signed-off-by: Adrian Bunk <bunk@stusta.de>
|
#
3f330317 |
| 03-Feb-2006 |
Pablo Neira Ayuso <pablo@netfilter.org> |
[TEXTSEARCH]: Fix broken good shift array calculation in Boyer-Moore
The current logic does not calculate correctly the good shift array: Let x be the pattern that is being searched. Let y be the bl
[TEXTSEARCH]: Fix broken good shift array calculation in Boyer-Moore
The current logic does not calculate correctly the good shift array: Let x be the pattern that is being searched. Let y be the block of data. The good shift array aligns the segment:
x[i+1 ... m-1] = y[i+j+1 ... j+m-1]
with its rightmost occurrence in x that fulfils x[i] neq y[i+j].
In previous version, the good shift array for the pattern ANPANMAN is: [1, 8, 3, 8, 8, 8, 8, 8] and should be: [1, 8, 3, 6, 6, 6, 6, 6]
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: David S. Miller <davem@davemloft.net>
show more ...
|
#
dd0fc66f |
| 07-Oct-2005 |
Al Viro <viro@ftp.linux.org.uk> |
[PATCH] gfp flags annotations - part 1
- added typedef unsigned int __nocast gfp_t;
- replaced __nocast uses for gfp flags with gfp_t - it gives exactly the same warnings as far as sparse is c
[PATCH] gfp flags annotations - part 1
- added typedef unsigned int __nocast gfp_t;
- replaced __nocast uses for gfp flags with gfp_t - it gives exactly the same warnings as far as sparse is concerned, doesn't change generated code (from gcc point of view we replaced unsigned int with typedef) and documents what's going on far better.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
show more ...
|
#
3d2aef66 |
| 05-Oct-2005 |
Randy Dunlap <rdunlap@xenotime.net> |
[TEXTSEARCH]: fix sparse gfp nocast warnings
Fix nocast sparse warnings: include/linux/textsearch.h:165:57: warning: implicit cast to nocast type
Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
[TEXTSEARCH]: fix sparse gfp nocast warnings
Fix nocast sparse warnings: include/linux/textsearch.h:165:57: warning: implicit cast to nocast type
Signed-off-by: Randy Dunlap <rdunlap@xenotime.net> Signed-off-by: David S. Miller <davem@davemloft.net>
show more ...
|
#
8082e4ed |
| 25-Aug-2005 |
Pablo Neira Ayuso <pablo@eurodev.net> |
[LIB]: Boyer-Moore extension for textsearch infrastructure strike #2
Attached the implementation of the Boyer-Moore string search algorithm for the new textsearch infrastructure.
I've added as well
[LIB]: Boyer-Moore extension for textsearch infrastructure strike #2
Attached the implementation of the Boyer-Moore string search algorithm for the new textsearch infrastructure.
I've added as well a note about the limitations that this approach presents, as Thomas has remarked.
Signed-off-by: Pablo Neira Ayuso <pablo@eurodev.net> Signed-off-by: David S. Miller <davem@davemloft.net>
show more ...
|