]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Additional cleanup and refinement of the regexp.c extension.
authordrh <>
Sat, 27 Sep 2025 11:54:49 +0000 (11:54 +0000)
committerdrh <>
Sat, 27 Sep 2025 11:54:49 +0000 (11:54 +0000)
FossilOrigin-Name: 2b34b750b5528b6dda195bc1a3895dc3fe46e70cbf992a78111316e2726c1ade

ext/misc/regexp.c
manifest
manifest.uuid

index 92343bf03b17b8a2e977f993abe7b41e4f575608..597b135031e5b45f355731a5b2cf85ab62c355f7 100644 (file)
 ** regular expression in the O(N*M) performance bound is computed after
 ** this expansion.
 **
-** To help prevent DoS attacks, the size of the NFA is limit to
-** SQLITE_MAX_REGEXP states, default 9999.
+** To help prevent DoS attacks, the maximum size of the NFA is restricted.
 */
 #include <string.h>
 #include <stdlib.h>
 #include "sqlite3ext.h"
 SQLITE_EXTENSION_INIT1
 
-#ifndef SQLITE_MAX_REGEXP
-# define SQLITE_MAX_REGEXP 9999
-#endif
-
 /*
 ** The following #defines change the names of some functions implemented in
 ** this file to prevent name collisions with C-library functions of the
@@ -103,32 +98,6 @@ SQLITE_EXTENSION_INIT1
 #define RE_OP_BOUNDARY   17    /* Boundary between word and non-word */
 #define RE_OP_ATSTART    18    /* Currently at the start of the string */
 
-#if defined(SQLITE_DEBUG)
-/* Opcode names used for symbolic debugging */
-static const char *ReOpName[] = {
-  "EOF",
-  "MATCH",
-  "ANY",
-  "ANYSTAR",
-  "FORK",
-  "GOTO",
-  "ACCEPT",
-  "CC_INC",
-  "CC_EXC",
-  "CC_VALUE",
-  "CC_RANGE",
-  "WORD",
-  "NOTWORD",
-  "DIGIT",
-  "NOTDIGIT",
-  "SPACE",
-  "NOTSPACE",
-  "BOUNDARY",
-  "ATSTART",
-};
-#endif /* SQLITE_DEBUG */
-
-
 /* Each opcode is a "state" in the NFA */
 typedef unsigned short ReStateNumber;
 
@@ -380,7 +349,7 @@ re_match_end:
 
 /* Resize the opcode and argument arrays for an RE under construction.
 */
-static int re_resize(ReCompiled *p, int N){
+static int re_resize(ReCompiled *p, unsigned int N){
   char *aOp;
   int *aArg;
   if( N>p->mxAlloc ){ p->zErr = "REGEXP pattern too big"; return 1; }
@@ -419,7 +388,7 @@ static int re_append(ReCompiled *p, int op, int arg){
 /* Make a copy of N opcodes starting at iStart onto the end of the RE
 ** under construction.
 */
-static void re_copy(ReCompiled *p, int iStart, int N){
+static void re_copy(ReCompiled *p, int iStart, unsigned int N){
   if( p->nState+N>=p->nAlloc && re_resize(p, p->nAlloc*2+N) ) return;
   memcpy(&p->aOp[p->nState], &p->aOp[iStart], N*sizeof(p->aOp[0]));
   memcpy(&p->aArg[p->nState], &p->aArg[iStart], N*sizeof(p->aArg[0]));
@@ -673,8 +642,7 @@ static const char *re_subcompile_string(ReCompiled *p){
 ** regular expression.  Applications should invoke this routine once
 ** for every call to re_compile() to avoid memory leaks.
 */
-static void re_free(void *p){
-  ReCompiled *pRe = (ReCompiled*)p;
+static void re_free(ReCompiled *pRe){
   if( pRe ){
     sqlite3_free(pRe->aOp);
     sqlite3_free(pRe->aArg);
@@ -838,6 +806,27 @@ static void re_bytecode_func(
   int n;
   char *z;
   (void)argc;
+  static const char *ReOpName[] = {
+    "EOF",
+    "MATCH",
+    "ANY",
+    "ANYSTAR",
+    "FORK",
+    "GOTO",
+    "ACCEPT",
+    "CC_INC",
+    "CC_EXC",
+    "CC_VALUE",
+    "CC_RANGE",
+    "WORD",
+    "NOTWORD",
+    "DIGIT",
+    "NOTDIGIT",
+    "SPACE",
+    "NOTSPACE",
+    "BOUNDARY",
+    "ATSTART",
+  };
 
   zPattern = (const char*)sqlite3_value_text(argv[0]);
   if( zPattern==0 ) return;
index a93995084138a7db00e86b191a2f5ca6f43a2063..1bde230d6a773551226055c8cee90ee8e55ae505 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Teach\sc-pp\show\sto\sreplace\sconfigure-script-like\s@tokens@,\sgiving\sus\sa\smuch\ssimpler\sway\sto\sget\sthe\sproper\sWASM\sfile\sname\sinjected\sinto\seach\sJS\sbuild.
-D 2025-09-27T11:38:35.546
+C Additional\scleanup\sand\srefinement\sof\sthe\sregexp.c\sextension.
+D 2025-09-27T11:54:49.147
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -389,7 +389,7 @@ F ext/misc/percentile.c 72e05a21db20a2fa85264b99515941f00ae698824c9db82d7edfbb16
 F ext/misc/prefixes.c 82645f79229877afab08c8b08ca1e7fa31921280906b90a61c294e4f540cd2a6
 F ext/misc/qpvtab.c fc189e127f68f791af90a487f4460ec91539a716daf45a0c357e963fd47cc06c
 F ext/misc/randomjson.c ef835fc64289e76ac4873b85fe12f9463a036168d7683cf2b773e36e6262c4ed
-F ext/misc/regexp.c b92da686f6d6915887758803b30c33fdd628aab055bbf6e1075ae579186be626
+F ext/misc/regexp.c 548151f3e57506fda678e6a65e85a763f4eece653287e1ad44e167f9485e0c6b
 F ext/misc/remember.c add730f0f7e7436cd15ea3fd6a90fd83c3f706ab44169f7f048438b7d6baa69c
 F ext/misc/rot13.c 51ac5f51e9d5fd811db58a9c23c628ad5f333c173f1fc53c8491a3603d38556c
 F ext/misc/scrub.c 2a44b0d44c69584c0580ad2553f6290a307a49df4668941d2812135bfb96a946
@@ -2169,8 +2169,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
 F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 1fa7e32d264f8329a8c9b0b5b469f1fc7ccadee86696d65e05df7fa3868af158
-R 3a56e0912785d2ab6d25423374f2119c
-U stephan
-Z 11190564f62030b343ceea51d93a998a
+P ffd5c8eaa89250a043b573c3eb66693dfec087a5b5eef184ae6d7bfbcf61235a
+R f2066338af0e932fc00c7fa52cabf422
+U drh
+Z ee84a7ef3181f55c87a3d826046de9a2
 # Remove this line to create a well-formed Fossil manifest.
index 88c32983fb7e34f46424ad1bee62feb02aad6f75..d89511ce53f06252e5c2dca472c1bf904c8c50c6 100644 (file)
@@ -1 +1 @@
-ffd5c8eaa89250a043b573c3eb66693dfec087a5b5eef184ae6d7bfbcf61235a
+2b34b750b5528b6dda195bc1a3895dc3fe46e70cbf992a78111316e2726c1ade