aboutsummaryrefslogtreecommitdiff
path: root/src/printf.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2020-05-23 19:58:07 +0000
committerdrh <drh@noemail.net>2020-05-23 19:58:07 +0000
commitdd6c33d372f3b83f4fe57904c2bd5ebba5c38018 (patch)
tree0c0e539e9b90f1af7e108d9a974677727b81cdd6 /src/printf.c
parent8e50d65aaf255c6db0631cfab8dc2b5329b5bb08 (diff)
downloadsqlite-dd6c33d372f3b83f4fe57904c2bd5ebba5c38018.tar.gz
sqlite-dd6c33d372f3b83f4fe57904c2bd5ebba5c38018.zip
Limit the "precision" of floating-point to text conversions in the printf()
function to 100,000,000. Fix for ticket [23439ea582241138]. FossilOrigin-Name: d08d3405878d394e08e5d3af281246edfbd81ca74cc8d16458808591512fb93d
Diffstat (limited to 'src/printf.c')
-rw-r--r--src/printf.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/printf.c b/src/printf.c
index fd42bd2bc..4505a5675 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -195,6 +195,13 @@ static char *printfTempBuf(sqlite3_str *pAccum, sqlite3_int64 n){
#define etBUFSIZE SQLITE_PRINT_BUF_SIZE /* Size of the output buffer */
/*
+** Hard limit on the precision of floating-point conversions.
+*/
+#ifndef SQLITE_PRINTF_PRECISION_LIMIT
+# define SQLITE_FP_PRECISION_LIMIT 100000000
+#endif
+
+/*
** Render a string given by "fmt" into the StrAccum object.
*/
void sqlite3_str_vappendf(
@@ -515,6 +522,11 @@ void sqlite3_str_vappendf(
length = 0;
#else
if( precision<0 ) precision = 6; /* Set default precision */
+#ifdef SQLITE_FP_PRECISION_LIMIT
+ if( precision>SQLITE_FP_PRECISION_LIMIT ){
+ precision = SQLITE_FP_PRECISION_LIMIT;
+ }
+#endif
if( realvalue<0.0 ){
realvalue = -realvalue;
prefix = '-';