]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Extra argument to sqlite3_atof() is returned if the input string is not 2-argument-atof
authordrh <>
Wed, 25 Mar 2026 16:13:10 +0000 (16:13 +0000)
committerdrh <>
Wed, 25 Mar 2026 16:13:10 +0000 (16:13 +0000)
perfectly well-formed.

FossilOrigin-Name: 85b07a4a329b317648699e78b275fae9e4489442b0e4d9189324d77b955138c5

manifest
manifest.tags
manifest.uuid
src/expr.c
src/resolve.c
src/shell.c.in
src/sqlite.h.in
src/sqlite3ext.h
src/util.c

index cc620d23ee4a7a5dadb6e454ecd26e3e4425dd5c..3470a448d315d7e937045ff50979793b5cd7300c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Prevent\soverly\slong\sJSON\spaths\sfrom\susing\stoo\smuch\sstack\sspace.
-D 2026-03-24T19:26:05.509
+C Extra\sargument\sto\ssqlite3_atof()\sis\sreturned\sif\sthe\sinput\sstring\sis\snot\nperfectly\swell-formed.
+D 2026-03-25T16:13:10.641
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -684,7 +684,7 @@ F src/date.c 61e92f1f7e2e88e1cd91e91dc69eb2b2854e7877254470f9fabd776bfac922b8
 F src/dbpage.c c9ea81c11727f27e02874611e92773e68e2a90a875ef2404b084564c235fd91f
 F src/dbstat.c 73362c0df0f40ad5523a6f5501224959d0976757b511299bf892313e79d14f5c
 F src/delete.c 1f2268d6fe3c78fc1bf794ba65d7026498b78e2342ffaf85825dedae546e6fde
-F src/expr.c b135746c5aaa80ec13225bfe3e5e46ad74377a7cea46630c1dab6b0409729fab
+F src/expr.c a277b38ed6b614b25b2bd04792b109b39b4d72f58520fdb3f3614d2ba5122dc4
 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
 F src/fkey.c 931f74cec1dc8038a0217ef340c91ce147dd1bbed08dc40c47ee0ec6edfffb08
 F src/func.c 6e7de3551ae0f8205006e5109f025223246edd20186d54d90746dee7c1c5c093
@@ -731,13 +731,13 @@ F src/pragma.c 789ef67117b74b5be0a2db6681f7f0c55e6913791b9da309aefd280de2c8a74d
 F src/prepare.c f6a6e28a281bd1d1da12f47d370a81af46159b40f73bf7fa0b276b664f9c8b7d
 F src/printf.c 9cff219dba73b1aa9a8113e83e962f03f7bea8b6eb51cefb25bc468d5a69fb2d
 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
-F src/resolve.c f0834917f2b1719d545a0d7eaad693283788f68ecd99871a81c7ff3b12b26209
+F src/resolve.c 635f215ca4bf3236ba22f9b375a7d819cf6097bafbb6dcd0b5c5cb25e455d5a6
 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
 F src/select.c ffe199f025a0dd74670d2a77232bdea364a4d7b36f32c64a6572d39ba6a11576
-F src/shell.c.in 38f05b2dde7e1de21d5499bdf6cad979a51e277c0b268997d40f5054d53a2236
-F src/sqlite.h.in b2b7d9ee568cc28fb659dff932881a3b00043b25d7463dbfc26bcb91d70ad2c3
+F src/shell.c.in f52bb3d92d623765fc85b195ef34af30fdf4cac58e646b39a3c38cac975fc364
+F src/sqlite.h.in fa62817969e039fc41821e77d1de6d6614f55594f778a818a8ee79cc0a1775d3
 F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479
-F src/sqlite3ext.h 5d48df11327acaabc45690a1957f0f4643e07afd9f77c5f2326115239fe5a3bc
+F src/sqlite3ext.h b085f71f6b5d610e0b9c45ef2752894598c7e2a67b2f5558c9ec82442ef592ca
 F src/sqliteInt.h 9716721fb57e32938a1d30a84560ce7633c63860a2209e188c87afad15d4b464
 F src/sqliteLimit.h 904a3f520362c7065c18165aaabd504fb13cc1b76cb411f38bd41ac219e4af1e
 F src/status.c 7565d63a79aa2f326339a24a0461a60096d0bd2bce711fefb50b5c89335f3592
@@ -798,7 +798,7 @@ F src/trigger.c 4bf3bfb3851d165e4404a9f9e69357345f3f7103378c07e07139fdd8aeb7bd20
 F src/update.c 3e5e7ff66fa19ebe4d1b113d480639a24cc1175adbefabbd1a948a07f28e37cf
 F src/upsert.c 215328c3f91623c520ec8672c44323553f12caeb4f01b1090ebdca99fdf7b4f1
 F src/utf.c 7267c3fb9e2467020507601af3354c2446c61f444387e094c779dccd5ca62165
-F src/util.c 32e5aed34f20508356a297f4a28762ecd1db0c81bfcbe5aa9d9ebcc6a52b6a85
+F src/util.c 1cdaa3aeda6567b2b92953b8034ff13e6a0138a7b0bf3e827caecb7b90e68e06
 F src/vacuum.c d3d35d8ae893d419ade5fa196d761a83bddcbb62137a1a157ae751ef38b26e82
 F src/vdbe.c dbafc6f5762f9ae90d9dc9ed065a31743a8ceafbdbfb1a0a3a228921fb3cc36a
 F src/vdbe.h 70e862ac8a11b590f8c1eaac17a0078429d42bc4ea3f757a9af0f451dd966a71
@@ -2195,8 +2195,11 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
 F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
 F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
-P f8659b700c0088abe19ce65fec032c1005a1f750566488f4578256d41558770c
-R 758e0af8a0882e7e9923c695c5403a23
+P 82a0794814bbc095235f8158a4129a5d83f6af1b0c27cb56449ea32feb44faf5
+R 5d7836122dd27182b196781352b9b147
+T *branch * 2-argument-atof
+T *sym-2-argument-atof *
+T -sym-trunk *
 U drh
-Z 1af8ca46b9aa6ac26d04c5ed95b2b6cf
+Z dcce595f066901035394acccf1c9c58b
 # Remove this line to create a well-formed Fossil manifest.
index bec971799ff1b8ee641c166c7aeb22d12c785393..361bd6967ae6a3201440fb4aacf239876556e354 100644 (file)
@@ -1,2 +1,2 @@
-branch trunk
-tag trunk
+branch 2-argument-atof
+tag 2-argument-atof
index 81366cb24efa78b433bad34fe22554a9557d2223..078f00ea7f920fea472cc3dd961819e340dfe4e2 100644 (file)
@@ -1 +1 @@
-82a0794814bbc095235f8158a4129a5d83f6af1b0c27cb56449ea32feb44faf5
+85b07a4a329b317648699e78b275fae9e4489442b0e4d9189324d77b955138c5
index f2a19dc3e818ae61de0410d21beec9d5abef6825..32eb6f692ff9779bf76abce01434a3f4579d91e2 100644 (file)
@@ -4302,7 +4302,7 @@ sqlite3ExprCodeIN_oom_error:
 */
 static void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){
   if( ALWAYS(z!=0) ){
-    double value = sqlite3_atof(z);
+    double value = sqlite3_atof(z,0.0);
     assert( !sqlite3IsNaN(value) ); /* The new AtoF never returns NaN */
     if( negateFlag ) value = -value;
     sqlite3VdbeAddOp4Dup8(v, OP_Real, 0, iMem, 0, (u8*)&value, P4_REAL);
index 2920b779458f3d15c322d60736e53571933c7762..1a790dfa4ac4fc0c3d40fa74906e21dfcd05ba4d 100644 (file)
@@ -936,7 +936,7 @@ static int exprProbability(Expr *p){
   double r = -1.0;
   if( p->op!=TK_FLOAT ) return -1;
   assert( !ExprHasProperty(p, EP_IntValue) );
-  r = sqlite3_atof(p->u.zToken);
+  r = sqlite3_atof(p->u.zToken, 0.0);
   assert( r>=0.0 );
   if( r>1.0 ) return -1;
   return (int)(r*134217728.0);
index 51d00f2894bc243d324461268c75982aba466168..c1ed0ab1b1d31e861e995a7daef2a87b62fff711 100644 (file)
@@ -10406,7 +10406,7 @@ static int do_meta_command(const char *zLine, ShellState *p){
             return 1;
           }
           i++;
-          p->tmProgress = sqlite3_atof(azArg[i]);
+          p->tmProgress = sqlite3_atof(azArg[i], 0.0);
           if( p->tmProgress>0.0 ){
             p->flgProgress = SHELL_PROGRESS_QUIET|SHELL_PROGRESS_TMOUT;
             if( nn==0 ) nn = 100;
index 61ffd7ec945cf5363dba483ec20aedc6f47a6441..4cbe82fc8a1ea4016dfa8d9987a970d10772c714 100644 (file)
@@ -3233,24 +3233,27 @@ char *sqlite3_vsnprintf(int,char*,const char*, va_list);
 /*
 ** CAPI3REF: Text-to-float conversion
 **
-** The sqlite3_atof(X) interface returns a "double" derived from the
-** text representation of a floating point value in X.
+** The sqlite3_atof(X,Y) interface returns a "double" derived from the
+** text representation of a floating point value in X, or it returns Y
+** if the text in X is not a well-formed floating point value.
 ** This interface provides applications with access to the
 ** same text&rarr;float conversion routine used by SQLite for SQL parsing
-** and type coercion.  The sqlite3_atof(X) routine works like the standard
+** and type coercion.  The sqlite3_atof(X,Y) routine works like the standard
 ** C-library atof(X) routine with the following exceptions:
 **
 ** <ul>
 ** <li> Parsing of the input X is strict. If anything about X
-**      is not well-formed, 0.0 is returned.
+**      is not well-formed, Y is returned.  Even if X has a prefix
+**      which is a well-formed floating point value, Y is still returned
+**      rather than the value of the well-formed prefix of X.
 ** <li> Special values such like "INF", "INFINITY", and "NAN" are not
 **      recognized.
 ** <li> Hexadecimal floating point literals are not recognized.
-** <li> The current locale is ignored. The radix character is always ".".
+** <li> Locale is ignored. The radix character is always ".".
 ** <li> The sqlite3_atof() interface does not set errno.
 ** </ul>
 */
-double sqlite3_atof(const char*);
+double sqlite3_atof(const char *X, double Y);
 
 /*
 ** CAPI3REF: Memory Allocation Subsystem
index f11588fab56388c633b0f8208369c99651d44c9a..6f0385c4fcb292fde81a408086fa28e58724c8d5 100644 (file)
@@ -377,7 +377,7 @@ struct sqlite3_api_routines {
   int (*carray_bind)(sqlite3_stmt*,int,void*,int,int,void(*)(void*));
   int (*carray_bind_v2)(sqlite3_stmt*,int,void*,int,int,void(*)(void*),void*);
   /* Version 3.53.0 and later */
-  double (*atof)(const char*);
+  double (*atof)(const char*,double);
 };
 
 /*
index ae6932ed6d3fa2aad1c13f78296810f222e85a28..596219adfcd4f85a7fa7905b46bdcb4fe722c14f 100644 (file)
@@ -967,9 +967,9 @@ int sqlite3AtoF(const char *zIn, double *pResult){
 /*
 ** Access to sqlite3AtoF()
 */
-double sqlite3_atof(const char *z){
+double sqlite3_atof(const char *x, double y){
   double r;
-  return sqlite3AtoF(z,&r)>0 ? r : 0.0;
+  return sqlite3AtoF(x,&r)>0 ? r : y;
 }
 
 /*