summaryrefslogtreecommitdiff
path: root/indra/llvfs
diff options
context:
space:
mode:
authorAaron Brashears <aaronb@lindenlab.com>2007-02-02 17:28:58 +0000
committerAaron Brashears <aaronb@lindenlab.com>2007-02-02 17:28:58 +0000
commit305c74d5163c5e344a675d39ca2394a9e45bd2c2 (patch)
tree42836c4a6010b2b015156024d3cfb6bf64a48ad6 /indra/llvfs
parent54d89549df38bb61881583a3eb8d3645c107d79f (diff)
Result of svn merge -r57264:57370 svn+ssh://svn/svn/linden/branches/adroit.r40-68 into release.
Diffstat (limited to 'indra/llvfs')
-rw-r--r--indra/llvfs/lldir.cpp2
-rw-r--r--indra/llvfs/lldir_linux.cpp14
-rw-r--r--indra/llvfs/lldir_mac.cpp2
-rw-r--r--indra/llvfs/lldir_win32.cpp6
-rw-r--r--indra/llvfs/lllfsthread.cpp2
-rw-r--r--indra/llvfs/lllfsthread.h2
-rw-r--r--indra/llvfs/llvfile.cpp2
-rw-r--r--indra/llvfs/llvfile.h2
-rw-r--r--indra/llvfs/llvfs.cpp66
-rw-r--r--indra/llvfs/llvfsthread.h4
10 files changed, 66 insertions, 36 deletions
diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp
index 3c82b28c74..9f8d6c08d5 100644
--- a/indra/llvfs/lldir.cpp
+++ b/indra/llvfs/lldir.cpp
@@ -323,7 +323,7 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string &file
std::string LLDir::getTempFilename() const
{
LLUUID random_uuid;
- char uuid_str[64];
+ char uuid_str[64]; /* Flawfinder: ignore */
random_uuid.generate();
random_uuid.toString(uuid_str);
diff --git a/indra/llvfs/lldir_linux.cpp b/indra/llvfs/lldir_linux.cpp
index f5573797c9..bfa663d64b 100644
--- a/indra/llvfs/lldir_linux.cpp
+++ b/indra/llvfs/lldir_linux.cpp
@@ -32,7 +32,7 @@ static std::string getCurrentUserHome(char* fallback)
else
{
llinfos << "Couldn't detect home directory from passwd - trying $HOME" << llendl;
- const char *const home_env = getenv("HOME");
+ const char *const home_env = getenv("HOME"); /* Flawfinder: ignore */
if (home_env)
{
result_cstr = (char*) home_env;
@@ -54,7 +54,7 @@ LLDir_Linux::LLDir_Linux()
mCurrentDirCount = -1;
mDirp = NULL;
- char tmp_str[LL_MAX_PATH];
+ char tmp_str[LL_MAX_PATH]; /* Flawfinder: ignore */
getcwd(tmp_str, LL_MAX_PATH);
mExecutableFilename = "";
@@ -66,13 +66,13 @@ LLDir_Linux::LLDir_Linux()
mOSUserAppDir = "";
mLindenUserDir = tmp_str;
- char path [32];
+ char path [32]; /* Flawfinder: ignore */
// *NOTE: /proc/%d/exe doesn't work on FreeBSD. But that's ok,
// because this is the linux implementation.
- sprintf (path, "/proc/%d/exe", (int) getpid ());
- int rc = readlink (path, tmp_str, sizeof (tmp_str)-1);
+ snprintf (path, sizeof(path), "/proc/%d/exe", (int) getpid ()); /* Flawfinder: ignore */
+ int rc = readlink (path, tmp_str, sizeof (tmp_str)-1); /* Flawfinder: ignore */
if ( (rc != -1) && (rc <= ((int) sizeof (tmp_str)-1)) )
{
tmp_str[rc] = '\0'; //readlink() doesn't 0-terminate the buffer
@@ -109,7 +109,7 @@ void LLDir_Linux::initAppDirs(const std::string &app_name)
LLString upper_app_name(app_name);
LLString::toUpper(upper_app_name);
- char* app_home_env = getenv((upper_app_name + "_USER_DIR").c_str());
+ char* app_home_env = getenv((upper_app_name + "_USER_DIR").c_str()); /* Flawfinder: ignore */
if (app_home_env)
{
// user has specified own userappdir i.e. $SECONDLIFE_USER_DIR
@@ -307,7 +307,7 @@ void LLDir_Linux::getRandomFileInDir(const std::string &dirname, const std::stri
std::string LLDir_Linux::getCurPath()
{
- char tmp_str[LL_MAX_PATH];
+ char tmp_str[LL_MAX_PATH]; /* Flawfinder: ignore */
getcwd(tmp_str, LL_MAX_PATH);
return tmp_str;
}
diff --git a/indra/llvfs/lldir_mac.cpp b/indra/llvfs/lldir_mac.cpp
index c056f982c4..82d27a11e7 100644
--- a/indra/llvfs/lldir_mac.cpp
+++ b/indra/llvfs/lldir_mac.cpp
@@ -335,7 +335,7 @@ S32 LLDir_Mac::deleteFilesInDir(const std::string &dirname, const std::string &m
std::string LLDir_Mac::getCurPath()
{
- char tmp_str[LL_MAX_PATH];
+ char tmp_str[LL_MAX_PATH]; /* Flawfinder: ignore */
getcwd(tmp_str, LL_MAX_PATH);
return tmp_str;
}
diff --git a/indra/llvfs/lldir_win32.cpp b/indra/llvfs/lldir_win32.cpp
index 8c2ed48813..08ef3d83b8 100644
--- a/indra/llvfs/lldir_win32.cpp
+++ b/indra/llvfs/lldir_win32.cpp
@@ -45,9 +45,9 @@ LLDir_Win32::LLDir_Win32()
if (GetTempPath(MAX_PATH, w_str))
{
- if (wcslen(w_str))
+ if (wcslen(w_str)) /* Flawfinder: ignore */
{
- w_str[wcslen(w_str)-1] = '\0'; // remove trailing slash
+ w_str[wcslen(w_str)-1] = '\0'; /* Flawfinder: ignore */ // remove trailing slash
}
mTempDir = utf16str_to_utf8str(llutf16string(w_str));
}
@@ -342,7 +342,7 @@ DWORD GetDllVersion(LPCTSTR lpszDllName)
HINSTANCE hinstDll;
DWORD dwVersion = 0;
- hinstDll = LoadLibrary(lpszDllName);
+ hinstDll = LoadLibrary(lpszDllName); /* Flawfinder: ignore */
if(hinstDll)
{
diff --git a/indra/llvfs/lllfsthread.cpp b/indra/llvfs/lllfsthread.cpp
index 57b4bc6d47..6af638fd12 100644
--- a/indra/llvfs/lllfsthread.cpp
+++ b/indra/llvfs/lllfsthread.cpp
@@ -58,7 +58,7 @@ LLLFSThread::~LLLFSThread()
//----------------------------------------------------------------------------
-LLLFSThread::handle_t LLLFSThread::read(const LLString& filename,
+LLLFSThread::handle_t LLLFSThread::read(const LLString& filename, /* Flawfinder: ignore */
U8* buffer, S32 offset, S32 numbytes, U32 priority, U32 flags)
{
handle_t handle = generateHandle();
diff --git a/indra/llvfs/lllfsthread.h b/indra/llvfs/lllfsthread.h
index a55a2668b3..37a6e8bae5 100644
--- a/indra/llvfs/lllfsthread.h
+++ b/indra/llvfs/lllfsthread.h
@@ -89,7 +89,7 @@ public:
~LLLFSThread();
// Return a Request handle
- handle_t read(const LLString& filename,
+ handle_t read(const LLString& filename, /* Flawfinder: ignore */
U8* buffer, S32 offset, S32 numbytes, U32 pri=PRIORITY_NORMAL, U32 flags = 0);
handle_t write(const LLString& filename,
U8* buffer, S32 offset, S32 numbytes, U32 flags = 0);
diff --git a/indra/llvfs/llvfile.cpp b/indra/llvfs/llvfile.cpp
index ad26b44916..a4612233d3 100644
--- a/indra/llvfs/llvfile.cpp
+++ b/indra/llvfs/llvfile.cpp
@@ -116,7 +116,7 @@ U8* LLVFile::readFile(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, S
else
{
data = new U8[file_size];
- file.read(data, file_size);
+ file.read(data, file_size); /* Flawfinder: ignore */
if (file.getLastBytesRead() != (S32)file_size)
{
diff --git a/indra/llvfs/llvfile.h b/indra/llvfs/llvfile.h
index c00e843cad..7c04bea2ec 100644
--- a/indra/llvfs/llvfile.h
+++ b/indra/llvfs/llvfile.h
@@ -20,7 +20,7 @@ public:
LLVFile(LLVFS *vfs, const LLUUID &file_id, const LLAssetType::EType file_type, S32 mode = LLVFile::READ);
~LLVFile();
- BOOL read(U8 *buffer, S32 bytes, BOOL async = FALSE, F32 priority = 128.f);
+ BOOL read(U8 *buffer, S32 bytes, BOOL async = FALSE, F32 priority = 128.f); /* Flawfinder: ignore */
static U8* readFile(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, S32* bytes_read = 0);
void setReadPriority(const F32 priority);
BOOL isReadComplete();
diff --git a/indra/llvfs/llvfs.cpp b/indra/llvfs/llvfs.cpp
index 95d851cfcf..e57e56aaf0 100644
--- a/indra/llvfs/llvfs.cpp
+++ b/indra/llvfs/llvfs.cpp
@@ -110,7 +110,7 @@ public:
}
#ifdef LL_LITTLE_ENDIAN
- inline void swizzleCopy(void *dst, void *src, int size) { memcpy(dst, src, size); }
+ inline void swizzleCopy(void *dst, void *src, int size) { memcpy(dst, src, size); /* Flawfinder: ignore */}
#else
@@ -137,7 +137,7 @@ public:
else
{
// Perhaps this should assert...
- memcpy(dst, src, size);
+ memcpy(dst, src, size); /* Flawfinder: ignore */
}
}
@@ -151,7 +151,7 @@ public:
buffer +=4;
swizzleCopy(buffer, &mAccessTime, 4);
buffer +=4;
- memcpy(buffer, &mFileID.mData, 16);
+ memcpy(buffer, &mFileID.mData, 16); /* Flawfinder: ignore */
buffer += 16;
S16 temp_type = mFileType;
swizzleCopy(buffer, &temp_type, 2);
@@ -220,10 +220,15 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r
}
mValid = VFSVALID_OK;
mReadOnly = read_only;
- mIndexFilename = new char[strlen(index_filename) + 1];
- mDataFilename = new char[strlen(data_filename) + 1];
- strcpy(mIndexFilename, index_filename);
- strcpy(mDataFilename, data_filename);
+ mIndexFilename = new char[strlen(index_filename) + 1]; /* Flawfinder: ignore */
+ mDataFilename = new char[strlen(data_filename) + 1]; /* Flawfinder: ignore */
+ if (mIndexFilename == NULL || mDataFilename == NULL)
+ {
+ llerrs << "Memory Allocation Failure" << llendl;
+ return;
+ }
+ strcpy(mIndexFilename, index_filename); /* Flawfinder: ignore */
+ strcpy(mDataFilename, data_filename); /* Flawfinder: ignore */
const char *file_mode = mReadOnly ? "rb" : "r+b";
@@ -247,13 +252,23 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r
{
llwarns << "Can't open VFS data file " << mDataFilename << " attempting to use alternate" << llendl;
- char *temp_index = new char[strlen(mIndexFilename) + 10];
- char *temp_data = new char[strlen(mDataFilename) + 10];
+ char *temp_index = new char[strlen(mIndexFilename) + 10]; /* Flawfinder: ignore */
+ if (!temp_index)
+ {
+ llerrs << "Out of the memory in LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL read_only, const U32 presize, const BOOL remove_after_crash)" << llendl;
+ return;
+ }
+ char *temp_data = new char[strlen(mDataFilename) + 10]; /* Flawfinder: ignore */
+ if (!temp_data)
+ {
+ llerrs << "Out of the memory in LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL read_only, const U32 presize, const BOOL remove_after_crash)" << llendl;
+ return;
+ }
for (U32 count = 0; count < 256; count++)
{
- sprintf(temp_index, "%s.%u", mIndexFilename, count);
- sprintf(temp_data, "%s.%u", mDataFilename, count);
+ sprintf(temp_index, "%s.%u", mIndexFilename, count); /* Flawfinder: ignore */
+ sprintf(temp_data, "%s.%u", mDataFilename, count); /* Flawfinder: ignore */
// try just opening, then creating, each alternate
if ((mDataFP = openAndLock(temp_data, "r+b", FALSE)))
@@ -294,8 +309,13 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r
if (!mReadOnly && mRemoveAfterCrash)
{
llstat marker_info;
- char* marker = new char[strlen(mDataFilename) + strlen(".open") + 1];
- sprintf(marker, "%s.open", mDataFilename);
+ char* marker = new char[strlen(mDataFilename) + strlen(".open") + 1]; /* Flawfinder: ignore */
+ if (!marker )
+ {
+ llerrs << "Out of memory in LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL read_only, const U32 presize, const BOOL remove_after_crash)" << llendl;
+ return;
+ }
+ sprintf(marker, "%s.open", mDataFilename); /* Flawfinder: ignore */
if (!LLFile::stat(marker, &marker_info))
{
// marker exists, kill the lock and the VFS files
@@ -523,8 +543,13 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r
if (!mReadOnly && mRemoveAfterCrash)
{
char* marker = new char[strlen(mDataFilename) + strlen(".open") + 1];
- sprintf(marker, "%s.open", mDataFilename);
- FILE* marker_fp = LLFile::fopen(marker, "w");
+ if (!marker)
+ {
+ llerrs << "Out of memory in LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL read_only, const U32 presize, const BOOL remove_after_crash)" << llendl;
+ return;
+ }
+ sprintf(marker, "%s.open", mDataFilename); /* Flawfinder: ignore */
+ FILE* marker_fp = LLFile::fopen(marker, "w"); /* Flawfinder: ignore */
if (marker_fp)
{
fclose(marker_fp);
@@ -567,7 +592,12 @@ LLVFS::~LLVFS()
if (!mReadOnly && mRemoveAfterCrash)
{
char* marker_file = new char[strlen(mDataFilename) + strlen(".open") + 1];
- sprintf(marker_file, "%s.open", mDataFilename);
+ if (marker_file == NULL)
+ {
+ llerrs << "Memory Allocation Failure" << llendl;
+ return;
+ }
+ sprintf(marker_file, "%s.open", mDataFilename); /* Flawfinder: ignore */
LLFile::remove(marker_file);
delete [] marker_file;
marker_file = NULL;
@@ -2045,7 +2075,7 @@ FILE *LLVFS::openAndLock(const char *filename, const char *mode, BOOL read_lock)
// first test the lock in a non-destructive way
if (strstr(mode, "w"))
{
- fp = LLFile::fopen(filename, "rb");
+ fp = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */
if (fp)
{
fd = fileno(fp);
@@ -2060,7 +2090,7 @@ FILE *LLVFS::openAndLock(const char *filename, const char *mode, BOOL read_lock)
}
// now actually open the file for use
- fp = LLFile::fopen(filename, mode);
+ fp = LLFile::fopen(filename, mode); /* Flawfinder: ignore */
if (fp)
{
fd = fileno(fp);
diff --git a/indra/llvfs/llvfsthread.h b/indra/llvfs/llvfsthread.h
index 14a2fe0ba7..6839338813 100644
--- a/indra/llvfs/llvfsthread.h
+++ b/indra/llvfs/llvfsthread.h
@@ -64,7 +64,7 @@ public:
}
std::string getFilename()
{
- char tbuf[40];
+ char tbuf[40]; /* Flawfinder: ignore */
mFileID.toString(tbuf);
return std::string(tbuf);
}
@@ -97,7 +97,7 @@ public:
~LLVFSThread();
// Return a Request handle
- handle_t read(LLVFS* vfs, const LLUUID &file_id, const LLAssetType::EType file_type,
+ handle_t read(LLVFS* vfs, const LLUUID &file_id, const LLAssetType::EType file_type, /* Flawfinder: ignore */
U8* buffer, S32 offset, S32 numbytes, U32 pri=PRIORITY_NORMAL, U32 flags = 0);
handle_t write(LLVFS* vfs, const LLUUID &file_id, const LLAssetType::EType file_type,
U8* buffer, S32 offset, S32 numbytes, U32 flags);