aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2007-05-04 13:15:55 +0000
committerdrh <drh@noemail.net>2007-05-04 13:15:55 +0000
commit5bb3eb9b9ae6008a1e5ee6ffa9a75b1ef14d7f0f (patch)
tree95a6f87a3340c4292d0b03201c2512f567fc2cfd /src/os_unix.c
parent92d4d7a92e1a1e465a0d5fd3e9a42e90ddcbda4b (diff)
downloadsqlite-5bb3eb9b9ae6008a1e5ee6ffa9a75b1ef14d7f0f.tar.gz
sqlite-5bb3eb9b9ae6008a1e5ee6ffa9a75b1ef14d7f0f.zip
Eliminate all uses of sprintf() and strcpy(). These were not being
misused. But getting rid of them removes a library dependency. And it avoids warnings from the OpenBSD compiler. Ticket #2336. (CVS 3916) FossilOrigin-Name: ba4845b32bdf38e623c4f7246e6e327715bbba4b
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 281348b79..4d0b61798 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -959,7 +959,7 @@ int sqlite3UnixTempFileName(char *zBuf){
break;
}
do{
- sprintf(zBuf, "%s/"TEMP_FILE_PREFIX, zDir);
+ sqlite3_snprintf(SQLITE_TEMPNAME_SIZE, zBuf, "%s/"TEMP_FILE_PREFIX, zDir);
j = strlen(zBuf);
sqlite3Randomness(15, &zBuf[j]);
for(i=0; i<15; i++, j++){
@@ -2518,33 +2518,40 @@ static int allocateUnixFile(
}else{
*pNew = f;
switch(lockingStyle) {
- case afpLockingStyle:
+ case afpLockingStyle: {
/* afp locking uses the file path so it needs to be included in
** the afpLockingContext */
+ int nFilename;
pNew->pMethod = &sqlite3AFPLockingUnixIoMethod;
pNew->lockingContext =
sqlite3ThreadSafeMalloc(sizeof(afpLockingContext));
+ nFilename = strlen(zFilename)+1;
((afpLockingContext *)pNew->lockingContext)->filePath =
- sqlite3ThreadSafeMalloc(strlen(zFilename) + 1);
- strcpy(((afpLockingContext *)pNew->lockingContext)->filePath,
- zFilename);
+ sqlite3ThreadSafeMalloc(nFilename);
+ memcpy(((afpLockingContext *)pNew->lockingContext)->filePath,
+ zFilename, nFilename);
srandomdev();
break;
+ }
case flockLockingStyle:
/* flock locking doesn't need additional lockingContext information */
pNew->pMethod = &sqlite3FlockLockingUnixIoMethod;
break;
- case dotlockLockingStyle:
+ case dotlockLockingStyle: {
/* dotlock locking uses the file path so it needs to be included in
** the dotlockLockingContext */
+ int nFilename;
pNew->pMethod = &sqlite3DotlockLockingUnixIoMethod;
pNew->lockingContext = sqlite3ThreadSafeMalloc(
sizeof(dotlockLockingContext));
+ nFilename = strlen(zFilename) + 6;
((dotlockLockingContext *)pNew->lockingContext)->lockPath =
- sqlite3ThreadSafeMalloc(strlen(zFilename) + strlen(".lock") + 1);
- sprintf(((dotlockLockingContext *)pNew->lockingContext)->lockPath,
+ sqlite3ThreadSafeMalloc( nFilename );
+ sqlite3_snprintf(nFilename,
+ ((dotlockLockingContext *)pNew->lockingContext)->lockPath,
"%s.lock", zFilename);
break;
+ }
case posixLockingStyle:
/* posix locking doesn't need additional lockingContext information */
pNew->pMethod = &sqlite3UnixIoMethod;