/ Check-in [e19eead8]
Login

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

Overview
Comment:Fix two potential (and apparently harmless) shift overflows discovered by the -fcatch-undefined-behavior option of clang.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:e19eead8c9977ed4f00eac54c5bc7e90db78caa8
User & Date: drh 2013-12-05 16:41:55
Context
2013-12-05
17:12
Fix harmless compiler warnings and improve the MSVC makefile. check-in: c6325670 user: drh tags: trunk
16:41
Fix two potential (and apparently harmless) shift overflows discovered by the -fcatch-undefined-behavior option of clang. check-in: e19eead8 user: drh tags: trunk
2013-12-03
19:49
Remove a branch in STAT4 logic that is no longer reachable after the previous change. check-in: eca7d3f1 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

  4077   4077       rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;
  4078   4078     }
  4079   4079   
  4080   4080     /* Update the global lock state and do debug tracing */
  4081   4081   #ifdef SQLITE_DEBUG
  4082   4082     { u16 mask;
  4083   4083     OSTRACE(("SHM-LOCK "));
  4084         -  mask = (1<<(ofst+n)) - (1<<ofst);
         4084  +  mask = ofst>31 ? 0xffffffff : (1<<(ofst+n)) - (1<<ofst);
  4085   4085     if( rc==SQLITE_OK ){
  4086   4086       if( lockType==F_UNLCK ){
  4087   4087         OSTRACE(("unlock %d ok", ofst));
  4088   4088         pShmNode->exclMask &= ~mask;
  4089   4089         pShmNode->sharedMask &= ~mask;
  4090   4090       }else if( lockType==F_RDLCK ){
  4091   4091         OSTRACE(("read-lock %d ok", ofst));

Changes to src/util.c.

  1277   1277   u64 sqlite3LogEstToInt(LogEst x){
  1278   1278     u64 n;
  1279   1279     if( x<10 ) return 1;
  1280   1280     n = x%10;
  1281   1281     x /= 10;
  1282   1282     if( n>=5 ) n -= 2;
  1283   1283     else if( n>=1 ) n -= 1;
  1284         -  if( x>=3 ) return (n+8)<<(x-3);
         1284  +  if( x>=3 ){
         1285  +    return x>60 ? (u64)LARGEST_INT64 : (n+8)<<(x-3);
         1286  +  }
  1285   1287     return (n+8)>>(3-x);
  1286   1288   }