Discussion:
Problem when using codesets
Zoltan Bordas
2009-01-06 20:28:59 UTC
Permalink
I found a problem when using UTF-8 encoding as the native codeset. When the response is being decoded the following code causes an access violation:

CORBA::Long
MICO::UniCodesetConv::decode (CORBA::Buffer &f, CORBA::ULong len,
CORBA::Char *t, CORBA::Boolean terminate)
{
char *cp, *to;

CORBA::ULong flen = _from->codepoint_size();
if (flen == 3)
flen = 4;
flen *= len;

if (len * _from->codepoint_size() > f.length()) {
return -1;
}

#ifdef __GNUG__
char _f[flen+1];
#else
CORBA::String_var _f;
if (_from->codepoint_size() != 1)
_f = CORBA::string_alloc (flen);
#endif

<<<< Access violation - _f is uninitialized >>>> if (!f.get (_f, len * _from->codepoint_size())) {
return -1;

The condition needs to be removed from the string initialization otherwise we are calling the get method to an uninitialized string.

Zoltan

--- codeset.cc.original 2008-07-25 16:41:44.000000000 -0500
+++ codeset.cc 2009-01-06 13:11:54.531250000 -0600
@@ -720,9 +720,7 @@
#ifdef __GNUG__
char _f[flen+1];
#else
- CORBA::String_var _f;
- if (_from->codepoint_size() != 1)
- _f = CORBA::string_alloc (flen);
+ CORBA::String_var _f = CORBA::string_alloc (flen);
#endif

if (!f.get (_f, len * _from->codepoint_size())) {
Karel Gardas
2009-01-08 08:56:19 UTC
Permalink
Indeed! This is like in case of CORBA::Long
MICO::UniCodesetConv::decode (CORBA::Buffer &f, CORBA::ULong len,
CORBA::WChar *t, CORBA::Boolean terminate)
method below the code.

Thanks, the fix is applied now!
Karel
Post by Zoltan Bordas
CORBA::Long
MICO::UniCodesetConv::decode (CORBA::Buffer &f, CORBA::ULong len,
CORBA::Char *t, CORBA::Boolean terminate)
{
char *cp, *to;
CORBA::ULong flen = _from->codepoint_size();
if (flen == 3)
flen = 4;
flen *= len;
if (len * _from->codepoint_size() > f.length()) {
return -1;
}
#ifdef __GNUG__
char _f[flen+1];
#else
CORBA::String_var _f;
if (_from->codepoint_size() != 1)
_f = CORBA::string_alloc (flen);
#endif
<<<< Access violation - _f is uninitialized >>>> if (!f.get (_f, len * _from->codepoint_size())) {
return -1;
The condition needs to be removed from the string initialization otherwise we are calling the get method to an uninitialized string.
Zoltan
--- codeset.cc.original 2008-07-25 16:41:44.000000000 -0500
+++ codeset.cc 2009-01-06 13:11:54.531250000 -0600
@@ -720,9 +720,7 @@
#ifdef __GNUG__
char _f[flen+1];
#else
- CORBA::String_var _f;
- if (_from->codepoint_size() != 1)
- _f = CORBA::string_alloc (flen);
+ CORBA::String_var _f = CORBA::string_alloc (flen);
#endif
if (!f.get (_f, len * _from->codepoint_size())) {
------------------------------------------------------------------------
_______________________________________________
Mico-devel mailing list
http://www.mico.org/mailman/listinfo/mico-devel
--
Karel Gardas ***@objectsecurity.com
ObjectSecurity Ltd. http://www.objectsecurity.com
Loading...