summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2010-01-22 16:56:34 +0000
committerAlbrecht Schlosser <albrechts.fltk@online.de>2010-01-22 16:56:34 +0000
commit430eab49b773887a45c3a231472ee203abd8602b (patch)
tree0859f2a1a669991f4f07ecb2c8e2d952b9c97162
parentff29502d04f3becf5816705fa9b4437382084a47 (diff)
Fixed a buffer overflow in fl_utf8from_mb() (STR #2279).
Todo: fix _WIN32 vs. WIN32 compiler macro issues. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7021 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--CHANGES5
-rw-r--r--src/fl_utf.c8
2 files changed, 7 insertions, 6 deletions
diff --git a/CHANGES b/CHANGES
index 9b7b16fad..5ebbfceae 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,9 +1,10 @@
CHANGES IN FLTK 1.3.0
+ - Fixed a buffer overflow in fl_utf8from_mb() (STR #2279)
- Fixed a Windows GDI leak when testing alpha blending capabilities
- - Fixed a name conflict with new (VC 2008 Express) winsock2.h
+ - Fixed a name conflict with new (VS 2008 Express) winsock2.h
versions and another conflict that produced compile errors
- with VC 2008 (STR #2301).
+ with VS 2008 Express (STR #2301)
- Widgets now remove stale entries from the default callback
queue when they are deleted (STR #2302)
- Moved OS X code base to the more moder Cocoa toolkit thanks
diff --git a/src/fl_utf.c b/src/fl_utf.c
index 5e1537894..eb130b4bf 100644
--- a/src/fl_utf.c
+++ b/src/fl_utf.c
@@ -776,13 +776,13 @@ unsigned fl_utf8from_mb(char* dst, unsigned dstlen,
{
if (!fl_utf8locale()) {
#ifdef _WIN32
+#warning _WIN32 alarm
wchar_t lbuf[1024];
wchar_t* buf = lbuf;
unsigned length;
unsigned ret;
- length =
- MultiByteToWideChar(GetACP(), 0, src, srclen, buf, 1024);
- if (length >= 1024) {
+ length = MultiByteToWideChar(GetACP(), 0, src, srclen, buf, 1024);
+ if ((length == 0)&&(GetLastError()==ERROR_INSUFFICIENT_BUFFER)) {
length = MultiByteToWideChar(GetACP(), 0, src, srclen, 0, 0);
buf = (wchar_t*)(malloc(length*sizeof(wchar_t)));
MultiByteToWideChar(GetACP(), 0, src, srclen, buf, length);
@@ -798,7 +798,7 @@ unsigned fl_utf8from_mb(char* dst, unsigned dstlen,
length = mbstowcs(buf, src, 1024);
if (length >= 1024) {
length = mbstowcs(0, src, 0)+1;
- buf = (wchar_t*)(malloc(length*sizeof(unsigned short)));
+ buf = (wchar_t*)(malloc(length*sizeof(wchar_t)));
mbstowcs(buf, src, length);
}
if (length >= 0) {