summaryrefslogtreecommitdiff
path: root/indra/llwindow
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwindow')
-rw-r--r--indra/llwindow/lldxhardware.cpp8
-rw-r--r--indra/llwindow/llkeyboard.cpp2
-rw-r--r--indra/llwindow/llwindowmacosx.cpp14
-rw-r--r--indra/llwindow/llwindowsdl.cpp49
-rw-r--r--indra/llwindow/llwindowwin32.cpp30
5 files changed, 62 insertions, 41 deletions
diff --git a/indra/llwindow/lldxhardware.cpp b/indra/llwindow/lldxhardware.cpp
index a972a29aa4..dc3edadb9c 100644
--- a/indra/llwindow/lldxhardware.cpp
+++ b/indra/llwindow/lldxhardware.cpp
@@ -47,16 +47,16 @@ std::string get_string(IDxDiagContainer *containerp, WCHAR *wszPropName)
switch( var.vt )
{
case VT_UI4:
- swprintf( wszPropValue, L"%d", var.ulVal );
+ swprintf( wszPropValue, L"%d", var.ulVal ); /* Flawfinder: ignore */
break;
case VT_I4:
- swprintf( wszPropValue, L"%d", var.lVal );
+ swprintf( wszPropValue, L"%d", var.lVal ); /* Flawfinder: ignore */
break;
case VT_BOOL:
- wcscpy( wszPropValue, (var.boolVal) ? L"true" : L"false" );
+ wcscpy( wszPropValue, (var.boolVal) ? L"true" : L"false" ); /* Flawfinder: ignore */
break;
case VT_BSTR:
- wcsncpy( wszPropValue, var.bstrVal, 255 );
+ wcsncpy( wszPropValue, var.bstrVal, 255 ); /* Flawfinder: ignore */
wszPropValue[255] = 0;
break;
}
diff --git a/indra/llwindow/llkeyboard.cpp b/indra/llwindow/llkeyboard.cpp
index 31db4cabf2..91c5fe30e7 100644
--- a/indra/llwindow/llkeyboard.cpp
+++ b/indra/llwindow/llkeyboard.cpp
@@ -311,7 +311,7 @@ LLString LLKeyboard::stringFromKey(KEY key)
LLString res = get_if_there(sKeysToNames, key, LLString::null);
if (res.empty())
{
- char buffer[2];
+ char buffer[2]; /* Flawfinder: ignore */
buffer[0] = key;
buffer[1] = '\0';
res = LLString(buffer);
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index 4d75a30a8e..a32013a5ee 100644
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -70,8 +70,8 @@ BOOL check_for_card(const char* RENDERER, const char* bad_card)
{
if (!strnicmp(RENDERER, bad_card, strlen(bad_card)))
{
- char buffer[1024];
- sprintf(buffer,
+ char buffer[1024];/* Flawfinder: ignore */
+ snprintf(buffer, sizeof(buffer), /* Flawfinder: ignore */
"Your video card appears to be a %s, which Second Life does not support.\n"
"\n"
"Second Life requires a video card with 32 Mb of memory or more, as well as\n"
@@ -227,8 +227,8 @@ LLWindowMacOSX::LLWindowMacOSX(char *title, char *name, S32 x, S32 y, S32 width,
mOriginalAspectRatio = (double)CGDisplayPixelsWide(mDisplay) / (double)CGDisplayPixelsHigh(mDisplay);
// Stash the window title
- strcpy((char*)mWindowTitle + 1, title);
- mWindowTitle[0] = strlen(title);
+ strcpy((char*)mWindowTitle + 1, title); /* Flawfinder: ignore */
+ mWindowTitle[0] = strlen(title); /* Flawfinder: ignore */
mEventHandlerUPP = NewEventHandlerUPP(staticEventHandler);
mGlobalHandlerRef = NULL;
@@ -405,8 +405,8 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits
mFullscreenBits = -1;
mFullscreenRefresh = -1;
- char error[256];
- sprintf(error, "Unable to run fullscreen at %d x %d.\nRunning in window.", width, height);
+ char error[256]; /* Flawfinder: ignore */
+ snprintf(error, sizeof(error), "Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); /* Flawfinder: ignore */
OSMessageBox(error, "Error", OSMB_OK);
}
}
@@ -2719,7 +2719,7 @@ void spawn_web_browser(const char* escaped_url)
S32 i;
for (i = 0; i < gURLProtocolWhitelistCount; i++)
{
- S32 len = strlen(gURLProtocolWhitelist[i]);
+ S32 len = strlen(gURLProtocolWhitelist[i]); /* Flawfinder: ignore */
if (!strncmp(escaped_url, gURLProtocolWhitelist[i], len)
&& escaped_url[len] == ':')
{
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp
index a2a4becf7f..9f9f762663 100644
--- a/indra/llwindow/llwindowsdl.cpp
+++ b/indra/llwindow/llwindowsdl.cpp
@@ -134,8 +134,8 @@ BOOL check_for_card(const char* RENDERER, const char* bad_card)
{
if (!strncasecmp(RENDERER, bad_card, strlen(bad_card)))
{
- char buffer[1024];
- sprintf(buffer,
+ char buffer[1024]; /* Flawfinder: ignore */
+ snprintf(buffer, sizeof(buffer), /* Flawfinder: ignore */
"Your video card appears to be a %s, which Second Life does not support.\n"
"\n"
"Second Life requires a video card with 32 Mb of memory or more, as well as\n"
@@ -197,9 +197,14 @@ LLWindowSDL::LLWindowSDL(char *title, S32 x, S32 y, S32 width,
title = "SDL Window"; // *FIX: (???)
// Stash the window title
- mWindowTitle = new char[strlen(title) + 1];
- strcpy(mWindowTitle, title);
+ mWindowTitle = new char[strlen(title) + 1]; /* Flawfinder: ignore */
+ if(mWindowTitle == NULL)
+ {
+ llerrs << "Memory allocation failure" << llendl;
+ return;
+ }
+ strcpy(mWindowTitle, title); /* Flawfinder: ignore */
// Create the GL context and set it up for windowed or fullscreen, as appropriate.
if(createContext(x, y, width, height, 32, fullscreen, disable_vsync))
{
@@ -223,10 +228,10 @@ LLWindowSDL::LLWindowSDL(char *title, S32 x, S32 y, S32 width,
static SDL_Surface *Load_BMP_Resource(const char *basename)
{
const int PATH_BUFFER_SIZE=1000;
- char path_buffer[PATH_BUFFER_SIZE];
+ char path_buffer[PATH_BUFFER_SIZE]; /* Flawfinder: ignore */
// Figure out where our BMP is living on the disk
- snprintf(path_buffer, PATH_BUFFER_SIZE-1, "%s%sres-sdl%s%s",
+ snprintf(path_buffer, PATH_BUFFER_SIZE-1, "%s%sres-sdl%s%s", /* Flawfinder: ignore */
gDirUtilp->getAppRODataDir().c_str(),
gDirUtilp->getDirDelimiter().c_str(),
gDirUtilp->getDirDelimiter().c_str(),
@@ -396,8 +401,8 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
mFullscreenBits = -1;
mFullscreenRefresh = -1;
- char error[256];
- sprintf(error, "Unable to run fullscreen at %d x %d.\nRunning in window.", width, height);
+ char error[256]; /* Flawfinder: ignore */
+ snprintf(error, sizeof(error), "Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); /* Flawfinder: ignore */
OSMessageBox(error, "Error", OSMB_OK);
}
}
@@ -1060,9 +1065,9 @@ x11clipboard_type convert_format(int type)
{
/* completely arbitrary clipboard types... we don't actually use
these right now, and support is skeletal. */
- char format[sizeof(FORMAT_PREFIX)+8+1];
+ char format[sizeof(FORMAT_PREFIX)+8+1]; /* Flawfinder: ignore */
- sprintf(format, "%s%08lx", FORMAT_PREFIX, (unsigned long)type);
+ snprintf(format, sizeof(format), "%s%08lx", FORMAT_PREFIX, (unsigned long)type); /* Flawfinder: ignore */
return XInternAtom(SDL_Display, format, False);
}
}
@@ -1080,14 +1085,18 @@ convert_data(int type, char *dst, const char *src, int srclen)
{
case SDLCLIPTYPE('T', 'E', 'X', 'T'):
case SDLCLIPTYPE('U', 'T', 'F', '8'):
+ if (src == NULL)
+ {
+ break;
+ }
if ( srclen == 0 )
- srclen = strlen(src);
+ srclen = strlen(src); /* Flawfinder: ignore */
dstlen = srclen + 1;
if ( dst ) // assume caller made it big enough by asking us
{
- memcpy(dst, src, srclen);
+ memcpy(dst, src, srclen); /* Flawfinder: ignore */
dst[srclen] = '\0';
}
break;
@@ -1112,14 +1121,18 @@ convert_x11clipboard(int type, char *dst, const char *src, int srclen)
{
case SDLCLIPTYPE('U', 'T', 'F', '8'):
case SDLCLIPTYPE('T', 'E', 'X', 'T'):
+ if (src == NULL)
+ {
+ break;
+ }
if ( srclen == 0 )
- srclen = strlen(src);
+ srclen = strlen(src); /* Flawfinder: ignore */
dstlen = srclen + 1;
if ( dst ) // assume caller made it big enough by asking us
{
- memcpy(dst, src, srclen);
+ memcpy(dst, src, srclen); /* Flawfinder: ignore */
dst[srclen] = '\0';
}
break;
@@ -1451,7 +1464,11 @@ BOOL LLWindowSDL::copyTextToClipboard(const LLWString &s)
{
std::string utf8text = wstring_to_utf8str(s);
const char* cstr = utf8text.c_str();
- int cstrlen = strlen(cstr);
+ if (cstr == NULL)
+ {
+ return FALSE;
+ }
+ int cstrlen = strlen(cstr); /* Flawfinder: ignore */
int i;
for (i=0; i<cstrlen; ++i)
{
@@ -2442,7 +2459,7 @@ void spawn_web_browser(const char* escaped_url)
close(1);
close(2);
// end ourself by running the command
- execv(cmd.c_str(), argv);
+ execv(cmd.c_str(), argv); /* Flawfinder: ignore */
// if execv returns at all, there was a problem.
llwarns << "execv failure when trying to start " << cmd << llendl;
_exit(1); // _exit because we don't want atexit() clean-up!
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index 42a88b6cc3..535f94d855 100644
--- a/indra/llwindow/llwindowwin32.cpp
+++ b/indra/llwindow/llwindowwin32.cpp
@@ -77,10 +77,14 @@ void show_window_creation_error(const char* title)
BOOL check_for_card(const char* RENDERER, const char* bad_card)
{
- if (!strnicmp(RENDERER, bad_card, strlen(bad_card)))
+ if(bad_card == NULL)
{
- char buffer[1024];
- sprintf(buffer,
+ return FALSE;
+ }
+ if (!strnicmp(RENDERER, bad_card, strlen(bad_card))) /* Flawfinder: ignore */
+ {
+ char buffer[1024]; /* Flawfinder: ignore */
+ snprintf(buffer, sizeof(buffer), /* Flawfinder: ignore */
"Your video card appears to be a %s, which Second Life does not support.\n"
"\n"
"Second Life requires a video card with 32 Mb of memory or more, as well as\n"
@@ -329,8 +333,8 @@ LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width,
mFullscreenBits = -1;
mFullscreenRefresh = -1;
- char error[256];
- sprintf(error, "Unable to run fullscreen at %d x %d.\nRunning in window.", width, height);
+ char error[256]; /* Flawfinder: ignore */
+ snprintf(error, sizeof(error), "Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); /* Flawfinder: ignore */
OSMessageBox(error, "Error", OSMB_OK);
}
}
@@ -2450,7 +2454,7 @@ BOOL LLWindowWin32::copyTextToClipboard(const LLWString& wstr)
WCHAR* copy_utf16 = (WCHAR*) GlobalLock(hglobal_copy_utf16);
if (copy_utf16)
{
- memcpy(copy_utf16, out_utf16.c_str(), size_utf16);
+ memcpy(copy_utf16, out_utf16.c_str(), size_utf16); /* Flawfinder: ignore */
GlobalUnlock(hglobal_copy_utf16);
if (SetClipboardData(CF_UNICODETEXT, hglobal_copy_utf16))
@@ -2474,7 +2478,7 @@ BOOL LLWindowWin32::copyTextToClipboard(const LLWString& wstr)
char* copy = (char*) GlobalLock(hglobal_copy);
if( copy )
{
- memcpy(copy, out_s.c_str(), size);
+ memcpy(copy, out_s.c_str(), size); /* Flawfinder: ignore */
GlobalUnlock(hglobal_copy);
if (SetClipboardData(CF_TEXT, hglobal_copy))
@@ -2575,7 +2579,7 @@ BOOL LLWindowWin32::sendEmail(const char* address, const char* subject, const ch
}
else
{
- HINSTANCE hMAPIInst = LoadLibrary(L"MAPI32.DLL");
+ HINSTANCE hMAPIInst = LoadLibrary(L"MAPI32.DLL"); /* Flawfinder: ignore */
if(!hMAPIInst)
{
result = LL_EMAIL_MAPILOAD_FAILED;
@@ -3093,7 +3097,7 @@ void spawn_web_browser(const char* escaped_url )
S32 i;
for (i = 0; i < gURLProtocolWhitelistCount; i++)
{
- S32 len = strlen(gURLProtocolWhitelist[i]);
+ S32 len = strlen(gURLProtocolWhitelist[i]); /* Flawfinder: ignore */
if (!strncmp(escaped_url, gURLProtocolWhitelist[i], len)
&& escaped_url[len] == ':')
{
@@ -3112,8 +3116,8 @@ void spawn_web_browser(const char* escaped_url )
// Figure out the user's default web browser
// HKEY_CLASSES_ROOT\http\shell\open\command
- char reg_path_str[256];
- sprintf(reg_path_str, "%s\\shell\\open\\command", gURLProtocolWhitelistHandler[i]);
+ char reg_path_str[256]; /* Flawfinder: ignore */
+ snprintf(reg_path_str, sizeof(reg_path_str), "%s\\shell\\open\\command", gURLProtocolWhitelistHandler[i]); /* Flawfinder: ignore */
WCHAR reg_path_wstr[256];
mbstowcs(reg_path_wstr, reg_path_str, 1024);
@@ -3164,7 +3168,7 @@ void spawn_web_browser(const char* escaped_url )
// MS docs say to cast to int and compare to 32.
HWND our_window = NULL;
LPCWSTR directory_wstr = NULL;
- int retval = (int) ShellExecute(our_window,
+ int retval = (int) ShellExecute(our_window, /* Flawfinder: ignore */
L"open",
browser_exec_utf16.c_str(),
url_utf16.c_str(),
@@ -3188,7 +3192,7 @@ void shell_open( const char* file_path )
mbstowcs(wstr, file_path, 1024);
HWND our_window = NULL;
- int retval = (int) ShellExecute(our_window, L"open", wstr, NULL, NULL, SW_SHOWNORMAL);
+ int retval = (int) ShellExecute(our_window, L"open", wstr, NULL, NULL, SW_SHOWNORMAL); /* Flawfinder: ignore */
if (retval > 32)
{
llinfos << "ShellExecute success with " << retval << llendl;