[omniORB] Possible bug in _CORBA_Sequence_Array_Boolean

Jian Wu jian.wu at asml.com
Thu Sep 20 14:55:40 BST 2007


Hello,

During our project, we use gcc 2.x to compile omniorb and in this
version of gcc the sizeof Boolean is 4 bytes. However, omniorb has
missed this point in the followings functions. It assumes Boolean to be
always 1 bytes and then use performance accelartor s.put_octet_array()
in _CORBA_Sequence_Array_Boolean. 


In file ./include/omniORB4/seqTemplatedefns.h

 //////////////////////////////////////////////////////////////////////
template<class T, class T_slice, int dimension>
inline void
_CORBA_Sequence_Array_Boolean<T,T_slice,dimension>::operator>>=(cdrStrea
m& s) const
{
  this->pd_len >>= s;
  if (this->pd_len==0) return;
 
s.put_octet_array((_CORBA_Octet*)this->pd_buf,(int)this->pd_len*dimensio
n);
}

//////////////////////////////////////////////////////////////////////
template<class T, class T_slice, int dimension>
inline void
_CORBA_Sequence_Array_Boolean<T,T_slice,dimension>::operator<<=(cdrStrea
m& s)
{
  _CORBA_ULong l;
  l <<= s;
  if (!s.checkInputOverrun(1,l) || (this->pd_bounded && l >
this->pd_max)) {
    _CORBA_marshal_sequence_range_check_error(s);
    // never reach here
  }
  this->length(l);
  if (l==0) return;
  s.get_octet_array((_CORBA_Octet*)this->pd_buf,(int)l*dimension);
}
//////////////////////////////////////////////////////////////////////


The possible fix for this bug is:

#if SIZEOF_BOOL == 1
 
s.put_octet_array((_CORBA_Octet*)this->pd_buf,(int)this->pd_len*dimensio
n);
#else
  for (_CORBA_ULong i=0; i<this->pd_len; i++) {
    for (_CORBA_ULong j=0; j<dimension; j++) {
      s.marshalBoolean(*((_CORBA_Boolean*)(this->pd_buf[i]) + j));
    }
  }
#endif

#if SIZEOF_BOOL == 1
  s.get_octet_array((_CORBA_Octet*)this->pd_buf,(int)l*dimension);
#else
  for (_CORBA_ULong i=0; i<l; i++) {
    for (_CORBA_ULong j=0; j<dimension; j++) {
      *((_CORBA_Boolean*)(this->pd_buf[i]) + j) =  s.unmarshalBoolean();
    }
  }
#endif


Best regards,

Jian Wu





-- 
The information contained in this communication and any attachments is confidential and may be privileged, and is for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited.  Unless explicitly stated otherwise in the body of this communication or the attachment thereto (if any), the information is provided on an AS-IS basis without any express or implied warranties or liabilities.  To the extent you are relying on this information, you are doing so at your own risk.   If you are not the intended recipient, please notify the sender immediately by replying to this message and destroy all copies of this message and any attachments. ASML is neither liable for the proper and complete transmission of the information contained in this communication, nor for any delay in its receipt. 




More information about the omniORB-list mailing list