Fix test for buffer overrun in unixGettempname(). Fix for #3091. (CVS 5069)

FossilOrigin-Name: fc0ca647bd1c7c953bb0f3eb7d3471572fd18c34
This commit is contained in:
danielk1977 2008-04-30 08:56:10 +00:00
parent bf8a4341f1
commit f96d8aebf3
3 changed files with 14 additions and 9 deletions

View File

@ -1,5 +1,5 @@
C Zero\sthe\sper-pager\stemporary\sspace\sallocation\sto\savoid\swarnings\sfrom\nvalgrind.\s(CVS\s5068)
D 2008-04-29T15:38:59
C Fix\stest\sfor\sbuffer\soverrun\sin\sunixGettempname().\sFix\sfor\s#3091.\s(CVS\s5069)
D 2008-04-30T08:56:10
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in 25b3282a4ac39388632c2fb0e044ff494d490952
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -120,7 +120,7 @@ F src/os.c d811a3e1a152e03c98d3dd85f2b7aff0d7630cea
F src/os.h 2ee8b0dec88f946c5371919ffa0f2fe4ac0de2e6
F src/os_common.h e8b748b2f2ecc8a498e50bfe5d8721f189c19d2a
F src/os_os2.c 41015b3fa91568761eb10cbf6ca27a0624ba0bda
F src/os_unix.c fdec4e5ee5dd555a6ad4a69f38ab35f0788536b4
F src/os_unix.c 8cf512c4321c3114f053dc9eaae394db2dc03ebe
F src/os_win.c 3a60bddd07ea6f8adb2314dd5996ac97b988f403
F src/pager.c 268be1208002fab9202b3f29b490ba35615a697d
F src/pager.h 45ec2188593afd48a25c743529646771d75e83e4
@ -633,7 +633,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 1f5b18419bb4e2552ac26593381e2eb866bb67fd
R 6a7ccfeeb0015916b93125468973211a
U drh
Z 090b70d1bbb6df5e983e8c84abf88caa
P f854ae576ee0b223b86a1169178fc4399e8d08ce
R dc0d12af7248df7518eb5354b7eeb383
U danielk1977
Z 6533bd0cfc41b7cb37a38e5960f73499

View File

@ -1 +1 @@
f854ae576ee0b223b86a1169178fc4399e8d08ce
fc0ca647bd1c7c953bb0f3eb7d3471572fd18c34

View File

@ -2520,9 +2520,14 @@ static int unixGetTempname(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
zDir = azDirs[i];
break;
}
if( strlen(zDir) - sizeof(SQLITE_TEMP_FILE_PREFIX) - 17 <=0 ){
/* Check that the output buffer is large enough for the temporary file
** name. If it is not, return SQLITE_ERROR.
*/
if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 17) >= nBuf ){
return SQLITE_ERROR;
}
do{
assert( pVfs->mxPathname==MAX_PATHNAME );
sqlite3_snprintf(nBuf-17, zBuf, "%s/"SQLITE_TEMP_FILE_PREFIX, zDir);