openbsd-ports/x11/wxWidgets/patches/patch-src_common_resourc2_cpp
todd b25888b419 wxWidgets 2.4.2, C++ cross-platform GUI toolkit
www: http://www.wxwidgets.org/

from Andrew Dalgleish   < openbsd at ajd dot net dot au >
many thanks for much persistence!
2004-07-16 21:01:35 +00:00

66 lines
2.3 KiB
Plaintext

$OpenBSD: patch-src_common_resourc2_cpp,v 1.1.1.1 2004/07/16 21:01:35 todd Exp $
--- src/common/resourc2.cpp.orig Wed Jan 9 10:52:53 2002
+++ src/common/resourc2.cpp Wed Apr 30 14:31:53 2003
@@ -76,6 +76,8 @@
#include "wx/settings.h"
+#define min(a, b) (((a) < (b)) ? (a) : (b))
+
#if ((defined(__BORLANDC__) || defined(__SC__)) && defined(__WIN16__))
// Forward (private) declarations
@@ -116,7 +118,7 @@ bool wxReallocateResourceBuffer()
{
long newSize = wxResourceBufferSize + 1000;
char *tmp = new char[(int)newSize];
- strncpy(tmp, wxResourceBuffer, (int)wxResourceBufferCount);
+ strlcpy(tmp, wxResourceBuffer, newSize);
delete[] wxResourceBuffer;
wxResourceBuffer = tmp;
wxResourceBufferSize = newSize;
@@ -292,9 +294,9 @@ bool wxResourceReadOneResource(FILE *fd,
else if (strcmp(wxResourceBuffer, "static") != 0)
{
char buf[300];
- strcpy(buf, _("Found "));
- strncat(buf, wxResourceBuffer, 30);
- strcat(buf, _(", expected static, #include or #define\nwhilst parsing resource."));
+ strlcpy(buf, _("Found "), sizeof(buf));
+ strlcat(buf, wxResourceBuffer, min(30+1, sizeof(buf)));
+ strlcat(buf, _(", expected static, #include or #define\nwhilst parsing resource."), sizeof(buf));
wxLogWarning(buf);
return FALSE;
}
@@ -327,7 +329,7 @@ bool wxResourceReadOneResource(FILE *fd,
return FALSE;
}
char nameBuf[100];
- strncpy(nameBuf, wxResourceBuffer+1, 99);
+ strlcpy(nameBuf, wxResourceBuffer+1, sizeof(nameBuf));
// =
if (!wxGetResourceToken(fd))
@@ -1357,9 +1359,9 @@ bool wxResourceReadOneResourceString(cha
else if (strcmp(wxResourceBuffer, "static") != 0)
{
char buf[300];
- strcpy(buf, _("Found "));
- strncat(buf, wxResourceBuffer, 30);
- strcat(buf, _(", expected static, #include or #define\nwhilst parsing resource."));
+ strlcpy(buf, _("Found "), sizeof(buf));
+ strlcat(buf, wxResourceBuffer, min(30+1, sizeof(buf)));
+ strlcat(buf, _(", expected static, #include or #define\nwhilst parsing resource."), sizeof(buf));
wxLogWarning(buf);
return FALSE;
}
@@ -1392,7 +1394,7 @@ bool wxResourceReadOneResourceString(cha
return FALSE;
}
char nameBuf[100];
- strncpy(nameBuf, wxResourceBuffer+1, 99);
+ strlcpy(nameBuf, wxResourceBuffer+1, sizeof(nameBuf));
// =
if (!wxGetResourceTokenString(s))