Just return NULL or empty string if the input path is too long. This is
probably not ideal but it fixes a buffer overflow and all this code needs to
be rewritten to use wxFileName() anyhow so it's not worth doing anything more
at this moment.
Closes #15302.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74455
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
{
static wxChar buf[_MAXPATHLEN];
{
static wxChar buf[_MAXPATHLEN];
- // Local copy
- wxStrcpy (buf, path);
-
int l = wxStrlen(path);
int i = l - 1;
int l = wxStrlen(path);
int i = l - 1;
+ if ( i >= _MAXPATHLEN )
+ return NULL;
+
+ // Local copy
+ wxStrcpy (buf, path);
// Search backward for a backward or forward slash
while (i > -1)
// Search backward for a backward or forward slash
while (i > -1)
{
wxChar buf[_MAXPATHLEN];
{
wxChar buf[_MAXPATHLEN];
- // Local copy
- wxStrcpy(buf, path);
-
int l = path.length();
int i = l - 1;
int l = path.length();
int i = l - 1;
+ if ( i >= _MAXPATHLEN )
+ return wxString();
+
+ // Local copy
+ wxStrcpy(buf, path);
+
// Search backward for a backward or forward slash
while (i > -1)
{
// Search backward for a backward or forward slash
while (i > -1)
{