SQLite User Forum

Bug: Wrong/missing return value check of mmap function in lsm_unix.c
Login

Bug: Wrong/missing return value check of mmap function in lsm_unix.c

(1) By trisbauer on 2020-06-22 14:25:25 [link] [source]

There is a wrong/missing return value check of the mmap function in the file lsm_unix.c. The return value is checked against 0, but mmap returns MAP_FAILED (-1) on errors.

I created a pull request with a fix on the sqlcipher GitHub page but I was asked to forward this request to the SQLite team: https://github.com/sqlcipher/sqlcipher/pull/364

(2.1) By Stephan Beal (stephan) on 2020-06-22 15:32:59 edited from 2.0 in reply to 1 [source]

There is a wrong/missing return value check of the mmap function in the file lsm_unix.c. The return value is checked against 0, but mmap returns MAP_FAILED (-1) on errors.

mmap() returns a pointer, and 0 is equivalent to a NULL pointer.

Edit: nevermind. the man page clearly says that it returns a (void*)-1... which is weird, but okay. Sorry for the noise.

(3) By Dan Kennedy (dan) on 2020-06-22 16:03:04 in reply to 1 [link] [source]

(4) By trisbauer on 2020-06-22 20:15:21 in reply to 3 [link] [source]

No problem. I found this a bug by using the following script: https://github.com/hannob/mmapfail