public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Improve wcsstr
@ 2024-02-20 20:04 Adhemerval Zanella
  2024-02-20 20:04 ` [PATCH v2 1/3] string: Remove c_strstr from test-strstr Adhemerval Zanella
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Adhemerval Zanella @ 2024-02-20 20:04 UTC (permalink / raw)
  To: libc-alpha; +Cc: Noah Goldstein, Alexander Monakov

Different than strstr, wcsstr still uses an O(m*n) algorithm that might
be considered a security issue (although BZ 23865 was marked security-
since there is no actual application impact). 

The gnulib recently added a wrapper to fix it [1] and it is used as the
base de str-two-way.h implementation. This patch adds a similar
implementation, and different than strstr, neither the "shift table"
optimization nor the self-adapting filtering check is used because it
would result in a too-large shift table (and it also simplifies the
implementation bit).

The patchset also added a proper tests for wcsstr, based on strstr one.

[1] https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commit;h=9411c5e467cf60f6295b9fed306029f341a0f24f

Changes from v1:
* Add more tests from gnulib.
* Removed unused macros from wcsstr.

Adhemerval Zanella (3):
  string: Remove c_strstr from test-strstr
  wcsmbs: Add test-wcsstr
  wcsmbs: Ensure wcstr worst-case linear execution time (BZ 23865)

 string/test-strstr.c | 305 ++++++++++++++++++++++++++++++++++--------
 wcsmbs/Makefile      |   1 +
 wcsmbs/test-wcsstr.c |  20 +++
 wcsmbs/wcs-two-way.h | 312 +++++++++++++++++++++++++++++++++++++++++++
 wcsmbs/wcsstr.c      |  95 ++++---------
 5 files changed, 609 insertions(+), 124 deletions(-)
 create mode 100644 wcsmbs/test-wcsstr.c
 create mode 100644 wcsmbs/wcs-two-way.h

-- 
2.34.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-03-04 12:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-20 20:04 [PATCH v2 0/3] Improve wcsstr Adhemerval Zanella
2024-02-20 20:04 ` [PATCH v2 1/3] string: Remove c_strstr from test-strstr Adhemerval Zanella
2024-02-27  4:42   ` DJ Delorie
2024-02-27 12:11     ` Adhemerval Zanella Netto
2024-02-20 20:04 ` [PATCH v2 2/3] wcsmbs: Add test-wcsstr Adhemerval Zanella
2024-02-29  0:45   ` DJ Delorie
2024-03-01 15:52     ` Adhemerval Zanella Netto
2024-03-01 17:07       ` Adhemerval Zanella Netto
2024-02-20 20:04 ` [PATCH v2 3/3] wcsmbs: Ensure wcstr worst-case linear execution time (BZ 23865) Adhemerval Zanella
2024-02-29  5:19   ` DJ Delorie
2024-03-01 16:35     ` Adhemerval Zanella Netto
2024-03-01 19:23       ` DJ Delorie
2024-03-04 12:23         ` Adhemerval Zanella Netto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).