Browse Source

breakpad: remove MAX_PATH limits

It's unlikely the user path is that large, but just in case we are ready.

This fixes an issue where the result of _snwprintf() is not checked.
The wstringstream will only fail if there's no memory. At this point
further calls using std::map and breakpad will also fail.
pull/175/head
Steve Lhomme 1 year ago
parent
commit
05e7dae2fc
  1. 15
      bin/breakpad.cpp

15
bin/breakpad.cpp

@ -30,6 +30,7 @@
#include <memory> #include <memory>
#include <map> #include <map>
#include <string> #include <string>
#include <sstream>
using google_breakpad::ExceptionHandler; using google_breakpad::ExceptionHandler;
@ -47,10 +48,10 @@ extern "C"
void CheckCrashDump( const wchar_t* path ) void CheckCrashDump( const wchar_t* path )
{ {
wchar_t pattern[MAX_PATH]; std::wstringstream pattern;
WIN32_FIND_DATAW data; WIN32_FIND_DATAW data;
_snwprintf( pattern, MAX_PATH, L"%s/*.dmp", path ); pattern << path << L"/*.dmp";
HANDLE h = FindFirstFileW( pattern, &data ); HANDLE h = FindFirstFileW( pattern.str().c_str(), &data );
if (h == INVALID_HANDLE_VALUE) if (h == INVALID_HANDLE_VALUE)
return; return;
int answer = MessageBoxW( NULL, L"Ooops: VLC media player just crashed.\n" \ int answer = MessageBoxW( NULL, L"Ooops: VLC media player just crashed.\n" \
@ -61,17 +62,17 @@ void CheckCrashDump( const wchar_t* path )
params[L"ver"] = WIDEN(PACKAGE_VERSION); params[L"ver"] = WIDEN(PACKAGE_VERSION);
do do
{ {
wchar_t fullPath[MAX_PATH]; std::wstringstream fullPath;
_snwprintf( fullPath, MAX_PATH, L"%s/%s", path, data.cFileName ); fullPath << path << L'/' << data.cFileName;
if( answer == IDYES ) if( answer == IDYES )
{ {
std::map<std::wstring, std::wstring> files; std::map<std::wstring, std::wstring> files;
files[L"upload_file_minidump"] = fullPath; files[L"upload_file_minidump"] = fullPath.str();
google_breakpad::HTTPUpload::SendRequest( google_breakpad::HTTPUpload::SendRequest(
WIDEN( BREAKPAD_URL "/reports" ), params, files, WIDEN( BREAKPAD_URL "/reports" ), params, files,
NULL, NULL, NULL ); NULL, NULL, NULL );
} }
DeleteFileW( fullPath ); DeleteFileW( fullPath.str().c_str() );
} while ( FindNextFileW( h, &data ) ); } while ( FindNextFileW( h, &data ) );
FindClose(h); FindClose(h);
} }

Loading…
Cancel
Save