You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Martin Elzen <Ma...@usoft.com> on 2011/09/13 18:02:30 UTC

XalanUTF16Writer.hpp sizeof-buffer code incorrect?

Hi all,

Today a client of ours told us about a crash they were experiencing with the version of Xalan we use.
After looking into it, it seems to us that the sizeof-buffer determination within the first if in XalanUTF16Writer::write (line 119 of XalanUTF16Writer.cpp)
is not quite correct.
currently in the SVN version of today it is:
if (theLength > sizeof(m_buffer))

while we think it ought to be:
if (   theLength > (sizeof(m_buffer) / sizeof(value_type) )   )

has anyone else run into this?


Sincerely,
Martin








________________________________
The information contained in this communication is intended solely for the use of the individual or entity to whom it is addressed and others authorized to receive it. It may contain confidential or legally privileged information. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this information is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us immediately by forwarding this email to MailAdmin@usoft.com and then delete it from your system.

USoft is neither liable for the proper and complete transmission of the information contained in this communication nor for any delay in its receipt.

Re: XalanUTF16Writer.hpp sizeof-buffer code incorrect?

Posted by David Bertoni <db...@apache.org>.
On 9/13/2011 9:06 AM, Martin Elzen wrote:
> Uh, sorry, that code is in XalanUTF16Writer.hpp (the *header* file as
> opposed to the implementation file)
>
> *From:*Martin Elzen [mailto:Martin.Elzen@usoft.com]
> *Sent:* Tuesday, September 13, 2011 6:03 PM
> *To:* xalan-dev@xml.apache.org
> *Subject:* XalanUTF16Writer.hpp sizeof-buffer code incorrect?
>
> Hi all,
>
> Today a client of ours told us about a crash they were experiencing with
> the version of Xalan we use.
>
> After looking into it, it seems to us that the sizeof-buffer
> determination within the first if in XalanUTF16Writer::write (line 119
> of XalanUTF16Writer.cpp)
>
> is not quite correct.
>
> currently in the SVN version of today it is:
>
> if (theLength > sizeof(m_buffer))
>
> while we think it ought to be:
>
> if ( theLength > (sizeof(m_buffer) / sizeof(value_type) ) )
>
> has anyone else run into this?
Yes, you're correct, that's a bug. A bug which has existed for many, 
many years. I guess not too many people have been generating UTF-16 output.

I think a better fix is:

if (theLength > kBufferSize)

rather than:

if (theLength > sizeof(m_buffer) / sizeof(value_type))

Can you create a Jira issue to track this?

Thanks!

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


RE: XalanUTF16Writer.hpp sizeof-buffer code incorrect?

Posted by Martin Elzen <Ma...@usoft.com>.
Uh, sorry, that code is in XalanUTF16Writer.hpp (the *header* file as opposed to the implementation file)

From: Martin Elzen [mailto:Martin.Elzen@usoft.com]
Sent: Tuesday, September 13, 2011 6:03 PM
To: xalan-dev@xml.apache.org
Subject: XalanUTF16Writer.hpp sizeof-buffer code incorrect?

Hi all,

Today a client of ours told us about a crash they were experiencing with the version of Xalan we use.
After looking into it, it seems to us that the sizeof-buffer determination within the first if in XalanUTF16Writer::write (line 119 of XalanUTF16Writer.cpp)
is not quite correct.
currently in the SVN version of today it is:
if (theLength > sizeof(m_buffer))

while we think it ought to be:
if (   theLength > (sizeof(m_buffer) / sizeof(value_type) )   )

has anyone else run into this?


Sincerely,
Martin








________________________________
The information contained in this communication is intended solely for the use of the individual or entity to whom it is addressed and others authorized to receive it. It may contain confidential or legally privileged information. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this information is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us immediately by forwarding this email to MailAdmin@usoft.com and then delete it from your system.

USoft is neither liable for the proper and complete transmission of the information contained in this communication nor for any delay in its receipt.