/ Check-in [ef3a7c87]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Avoid the possibility of signed integer overflow with oversized precisions in %d conversions in the printf() implementation.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ef3a7c877a7549b351aafd983cfa96c863eb2641b6218bdd5cb563f659f879d8
User & Date: drh 2017-03-20 16:34:18
Context
2017-03-20
18:53
Fix some problems in fts3 found by address-sanitizer. check-in: 16a8e84f user: dan tags: trunk
16:34
Avoid the possibility of signed integer overflow with oversized precisions in %d conversions in the printf() implementation. check-in: ef3a7c87 user: drh tags: trunk
16:06
Do not run sync2.test as part of the "journaltest" permutation, as it uses "PRAGMA synchronous = off". check-in: 285005a9 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/printf.c.

   396    396           if( flag_zeropad && precision<width-(prefix!=0) ){
   397    397             precision = width-(prefix!=0);
   398    398           }
   399    399           if( precision<etBUFSIZE-10-etBUFSIZE/3 ){
   400    400             nOut = etBUFSIZE;
   401    401             zOut = buf;
   402    402           }else{
   403         -          nOut = precision + 10 + precision/3;
   404         -          zOut = zExtra = sqlite3Malloc( nOut );
          403  +          u64 n = (u64)precision + 10 + precision/3;
          404  +          zOut = zExtra = sqlite3Malloc( n );
   405    405             if( zOut==0 ){
   406    406               setStrAccumError(pAccum, STRACCUM_NOMEM);
   407    407               return;
   408    408             }
          409  +          nOut = (int)n;
   409    410           }
   410    411           bufpt = &zOut[nOut-1];
   411    412           if( xtype==etORDINAL ){
   412    413             static const char zOrd[] = "thstndrd";
   413    414             int x = (int)(longvalue % 10);
   414    415             if( x>=4 || (longvalue/10)%10==1 ){
   415    416               x = 0;