Buffer Underflow at os.unix.c:6015
(1) By stas24 (stasos24) on 2022-03-09 08:47:48 [link] [source]
static int findCreateFileMode( const char *zPath, /* Path of file (possibly) being created */ int flags, /* Flags passed as 4th argument to xOpen() */ mode_t *pMode, /* OUT: Permissions to open file with */ uid_t *pUid, /* OUT: uid to set on the file */ gid_t *pGid /* OUT: gid to set on the file */ ){ int rc = SQLITE_OK; /* Return Code */ *pMode = 0; *pUid = 0; *pGid = 0; if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){ char zDb[MAX_PATHNAME+1]; /* Database file path */ int nDb; /* Number of valid bytes in zDb */ /* zPath is a path to a WAL or journal file. The following block derives ** the path to the associated database file from zPath. This block handles ** the following naming conventions: ** ** "<path to db>-journal" ** "<path to db>-wal" ** "<path to db>-journalNN" ** "<path to db>-walNN" ** ** where NN is a decimal number. The NN naming schemes are ** used by the test_multiplex.c module. */ nDb = sqlite3Strlen30(zPath) - 1; //BufferUnderflow if zPath=0; while( zPath[nDb]!='-' ){ /* In normal operation, the journal file name will always contain ** a '-' character. However in 8+3 filename mode, or if a corrupt ** rollback journal specifies a super-journal with a goofy name, then ** the '-' might be missing. */ if( nDb==0 || zPath[nDb]=='.' ) return SQLITE_OK; nDb--; } memcpy(zDb, zPath, nDb); zDb[nDb] = '\0'; rc = getFileMode(zDb, pMode, pUid, pGid); }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){ *pMode = 0600; }else if( flags & SQLITE_OPEN_URI ){ /* If this is a main database file and the file was opened using a URI ** filename, check for the "modeof" parameter. If present, interpret ** its value as a filename and try to copy the mode, uid and gid from ** that file. */ const char *z = sqlite3_uri_parameter(zPath, "modeof"); if( z ){ rc = getFileMode(z, pMode, pUid, pGid); } } return rc; }
(2) By Stephan Beal (stephan) on 2022-03-09 08:56:29 in reply to 1 [link] [source]
Buffer Underflow at os.unix.c:6015
To save the next person the search for the Easter Egg, it's hidden around the middle of the code:
nDb = sqlite3Strlen30(zPath) - 1; //BufferUnderflow if zPath=0;
(3.1) By Richard Hipp (drh) on 2022-03-09 12:48:11 edited from 3.0 in reply to 1 [source]
This static-analyzer warning has now been addressed by check-in a9cda38997a692e2.
(4) By anonymous on 2022-03-09 12:37:56 in reply to 3.0 [link] [source]
You probably meant https://sqlite.org/src/info/a9cda38997a692e2 rather than a nonexistent wiki page.