]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix an off-by-one in c-pp-lite.c which could cause @token@-processed output to get...
authorstephan <stephan@noemail.net>
Thu, 16 Oct 2025 01:44:03 +0000 (01:44 +0000)
committerstephan <stephan@noemail.net>
Thu, 16 Oct 2025 01:44:03 +0000 (01:44 +0000)
FossilOrigin-Name: aa2f4c51604f4d4286c8a1ec7eaa6251892471e32087af695712513ee620ea46

ext/wasm/c-pp-lite.c
manifest
manifest.uuid

index acb64df6541aab8465a937b008eba451b5763577..ee3e71bbc05e51cc0fc8f4b3bdc604134acf31ee 100644 (file)
@@ -386,6 +386,9 @@ static void g_stderrv(char const *zFmt, va_list);
   if(lvl<=g.flags.doDebug) g_stderr("%s @ %s():%d: ",g.zArgv0,__func__,__LINE__); \
   if(lvl<=g.flags.doDebug) g_stderr pfexpr
 
+#define g_warn(zFmt,...) g_stderr("%s:%d %s() " zFmt "\n", __FILE__, __LINE__, __func__, __VA_ARGS__)
+#define g_warn0(zMsg) g_stderr("%s:%d %s() %s\n", __FILE__, __LINE__, __func__, zMsg)
+
 void cmpp_free(void *p){
   sqlite3_free(p);
 }
@@ -1468,6 +1471,9 @@ static inline void cmpp__skip_space_c( unsigned char const **p,
   *p = z;
 }
 
+#define ustr_c(X) ((unsigned char const *)X)
+//#define ustr_nc(X) ((unsigned char *)X)
+
 /**
    Scan [t->zPos,t->zEnd) for a derective delimiter. Emits any
    non-delimiter output found along the way.
@@ -1477,7 +1483,7 @@ static inline void cmpp__skip_space_c( unsigned char const **p,
    If a delimiter is found, it updates t->token and returns 0.
    On no match returns 0.
 */
-//static
+static
 int CmppTokenizer__delim_search(CmppTokenizer * const t){
   if(!t->zPos) t->zPos = t->zBegin;
   if( t->zPos>=t->zEnd ){
@@ -1621,16 +1627,21 @@ static void cmpp_t_out_expand(CmppTokenizer * const t,
   unsigned char const chEol = (unsigned char)'\n';
   int state = 0 /* 0==looking for opening @
                 ** 1==looking for closing @ */;
+  if( 0 ){
+    g_warn("zLeft=%d %c", (int)*zLeft, *zLeft);
+  }
 #define tflush \
+  if(z>zEnd) z=zEnd; \
   if(zLeft<z){ cmpp_t_out(t, zLeft, (z-zLeft)); } zLeft = z
   for( ; z<zEnd; ++z ){
     zLeft = z;
     for( ;z<zEnd; ++z ){
       if( chEol==*z ){
         state = 0;
-        ++z /*ensure that we flush the EOL now*/;
+        //This ++z/--z thing breaks stuff.
+        //++z /*ensure that we flush the EOL now*/;
         tflush;
-        --z/*And make sure that zLeft does the right thing*/;
+        //--z/*And make sure that zLeft does the right thing*/;
         break;
       }
       if( g.delim.chAt==*z ){
index 538b504b37e5741f447a9e05ec2099d6c4a8c1b0..8755d5e0f7ea213e90786b81cf874877890084e7 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Minor\sJS\sdoc\supdates.\sNo\scode\schanges.
-D 2025-10-15T23:28:31.291
+C Fix\san\soff-by-one\sin\sc-pp-lite.c\swhich\scould\scause\s@token@-processed\soutput\sto\sget\sone\sduplicated\sbyte.
+D 2025-10-16T01:44:03.950
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -608,7 +608,7 @@ F ext/wasm/api/sqlite3-vtab-helper.c-pp.js 9097074724172e31e56ce20ccd7482259cf72
 F ext/wasm/api/sqlite3-wasm.c dd7fc1d535281f0d5d2732bb1b662d1d403a762f07b63c2ea5663053377b2804
 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bda1c75bd674a92a0e27cc2f3d46dbbf21e422413f8046814515a0bd7409328a
 F ext/wasm/api/sqlite3-worker1.c-pp.js 802d69ead8c38dc1be52c83afbfc77e757da8a91a2e159e7ed3ecda8b8dba2e7
-F ext/wasm/c-pp-lite.c bea58ca9d07bc8f40c6348008ccbd197ae3e60f57319884fa92ac0f3659e9151
+F ext/wasm/c-pp-lite.c b2098c8abb8d42f061a53c6857fbc1863298dc8a2d9eb5f114fca67c36f39a68
 F ext/wasm/common/SqliteTestUtil.js 7adaeffef757d8708418dc9190f72df22367b531831775804b31598b44f6aa51
 F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15
 F ext/wasm/common/testing.css e97549bab24126c24e0daabfe2de9bb478fb0a69fdb2ddd0a73a992c091aad6f
@@ -2171,8 +2171,8 @@ F tool/version-info.c 33d0390ef484b3b1cb685d59362be891ea162123cea181cb8e6d2cf6dd
 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
 F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 7801c7225a18ccb2216b01663b30e3eb90a961e3d165af73f964c515b74fe745
-R 289dc770277d2a4b04582f3245dc80e2
+P fc2a026901b1a12526b92fff36d7acc226e554c9f351e6261c7ffd4887bcc337
+R aefa3e1273932bb6964a1ffca99335de
 U stephan
-Z 1f422acd6b6c526cea838b0fec76c94a
+Z 1edba660befee7f8d8136758f8fe56d1
 # Remove this line to create a well-formed Fossil manifest.
index f007688748844ab06a401a4a01828fb9ac1350b8..6d65cf04f7018e9fd012b844b7c588078c6129d9 100644 (file)
@@ -1 +1 @@
-fc2a026901b1a12526b92fff36d7acc226e554c9f351e6261c7ffd4887bcc337
+aa2f4c51604f4d4286c8a1ec7eaa6251892471e32087af695712513ee620ea46