From 305c74d5163c5e344a675d39ca2394a9e45bd2c2 Mon Sep 17 00:00:00 2001 From: Aaron Brashears Date: Fri, 2 Feb 2007 17:28:58 +0000 Subject: Result of svn merge -r57264:57370 svn+ssh://svn/svn/linden/branches/adroit.r40-68 into release. --- indra/llwindow/lldxhardware.cpp | 8 +++---- indra/llwindow/llkeyboard.cpp | 2 +- indra/llwindow/llwindowmacosx.cpp | 14 +++++------ indra/llwindow/llwindowsdl.cpp | 49 ++++++++++++++++++++++++++------------- indra/llwindow/llwindowwin32.cpp | 30 +++++++++++++----------- 5 files changed, 62 insertions(+), 41 deletions(-) (limited to 'indra/llwindow') 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 32) { llinfos << "ShellExecute success with " << retval << llendl; -- cgit v1.2.3