Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid copy of vector data block #8

Closed
kornefalk opened this issue Aug 5, 2015 · 1 comment
Closed

Invalid copy of vector data block #8

kornefalk opened this issue Aug 5, 2015 · 1 comment
Assignees

Comments

@kornefalk
Copy link

The copy of data are using invalid length

(value.size() + 1) * sizeof(otext)

The vector is ending at value.size(), not value.size()+1, ocilib_impl.hpp:4179

Why is the length multiplied with sizeof(otext) ?
The definition of Raw is

typedef std::vector<unsigned char> Raw;

and otext is either

  typedef char              otext;

or

  typedef wchar_t           otext;

which leads to invalid length when compiling with OCI_CHAR_WIDE (2 times bigger size than allowed + 2 extra bytes).

The line 4179 must be

           memcpy(_data + (_elemSize * index), &value[0], value.size() );
template<>
inline void BindArray::BindArrayObject<Raw, unsigned char>::SetInData()
{
    if (_mode & OCI_BDM_IN)
    {
        std::vector<Raw>::iterator it, it_end;

        unsigned int index = 0;
        unsigned int currElemCount = Check(OCI_BindArrayGetSize(_pStatement));

        for (it = _vector.begin(), it_end = _vector.end(); it != it_end && index < _elemCount && index < currElemCount; ++it, ++index)
        {
            Raw & value = *it;

            if (value.size() > 0)
            {
===>             memcpy(_data + (_elemSize * index), &value[0], (value.size() + 1) * sizeof(otext));
            }
        }
    }
}
@vrogier
Copy link
Owner

vrogier commented Aug 5, 2015

Hi,

Thanks again for reporting issues :)

This was due to a faulty copy and paste action coupled to a missed test in OCI_CHARSET_WIDE builds

Fix committed.

Regards,

Vincent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants