diff options
author | drh <drh@noemail.net> | 2013-12-05 16:41:55 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2013-12-05 16:41:55 +0000 |
commit | 47676fedf640e2433bde647a6c3343fa2e3a64c0 (patch) | |
tree | 4032029cbffd4e3403b72d06fc376a2c027af80c /src | |
parent | 7f59475fdaac1f487f32cc3604b15a7273b73631 (diff) | |
download | sqlite-47676fedf640e2433bde647a6c3343fa2e3a64c0.tar.gz sqlite-47676fedf640e2433bde647a6c3343fa2e3a64c0.zip |
Fix two potential (and apparently harmless) shift overflows discovered by
the -fcatch-undefined-behavior option of clang.
FossilOrigin-Name: e19eead8c9977ed4f00eac54c5bc7e90db78caa8
Diffstat (limited to 'src')
-rw-r--r-- | src/os_unix.c | 2 | ||||
-rw-r--r-- | src/util.c | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 501b1b769..ab657dc7b 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4081,7 +4081,7 @@ static int unixShmSystemLock( #ifdef SQLITE_DEBUG { u16 mask; OSTRACE(("SHM-LOCK ")); - mask = (1<<(ofst+n)) - (1<<ofst); + mask = ofst>31 ? 0xffffffff : (1<<(ofst+n)) - (1<<ofst); if( rc==SQLITE_OK ){ if( lockType==F_UNLCK ){ OSTRACE(("unlock %d ok", ofst)); diff --git a/src/util.c b/src/util.c index e59f5238f..9fa2a0fbd 100644 --- a/src/util.c +++ b/src/util.c @@ -1281,6 +1281,8 @@ u64 sqlite3LogEstToInt(LogEst x){ x /= 10; if( n>=5 ) n -= 2; else if( n>=1 ) n -= 1; - if( x>=3 ) return (n+8)<<(x-3); + if( x>=3 ){ + return x>60 ? (u64)LARGEST_INT64 : (n+8)<<(x-3); + } return (n+8)>>(3-x); } |