logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: TlsSyslogFrame calculates message length incorrectly
Date Thu, 21 Jan 2016 02:42:48 GMT
On Wed, Jan 20, 2016 at 6:37 PM, Blake Day <blake@chewy.com> wrote:

> I'm mobile so can't confirm, but utf-8 has multi-byte characters as well.
>

Ah, right, some code points can map from 1 to 4 bytes. The patch I proposed
should work for any String.

Gary


> > On Jan 20, 2016, at 9:32 PM, Gary Gregory <garydgregory@gmail.com>
> wrote:
> >
> >> On Wed, Jan 20, 2016 at 6:18 PM, Blake Day <blake@chewy.com> wrote:
> >>
> >> I'm not sure on that, but it wouldn't fix the erroneous byte count on
> log
> >> messages with a multi-byte unicode character.
> >
> > Please see my latest message.
> >
> > "multi-byte unicode character." Doesn't the spec call for UTF-8 as the
> only
> > encoding?
> >
> > Gary
> >
> >
> >>>> On Jan 20, 2016, at 9:04 PM, Gary Gregory <garydgregory@gmail.com>
> >>> wrote:
> >>>
> >>> Hm, shouldn't we be using UTF-8 instead of Charset.defaultCharset() in:
> >>>
> >>>   public byte[] getBytes() {
> >>>       final String frame = toString();
> >>>       return frame.getBytes(Charset.defaultCharset());
> >>>   }
> >>>
> >>> ?
> >>>
> >>> Gary
> >>>
> >>>> On Wed, Jan 20, 2016 at 4:58 PM, Blake Day <blake@chewy.com> wrote:
> >>>>
> >>>> TlsSyslogFrame appears to be miscalculating the message length.
> >> According
> >>>> to RFC5425, the message length must be the octet count of the
> >> SYSLOG-MSG in
> >>>> the frame.  Though the variable below is aptly named
> >> messageLengthInBytes,
> >>>> it is assigned the value from message.length() (where message is a
> >> String)
> >>>> rather than the bytes.
> >>>>
> >>>> See below for relevant portions of code:
> >>>>
> >>>> private String message;
> >>>> private int messageLengthInBytes;
> >>>>
> >>>> private void setLengthInBytes() {
> >>>>   messageLengthInBytes = message.length();
> >>>> }
> >>>>
> >>>> @Override
> >>>> public String toString() {
> >>>>   final String length = Integer.toString(messageLengthInBytes);
> >>>>   return length + Chars.SPACE + message;
> >>>> }
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
> >>>
> >>>
> >>> --
> >>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> >>> Java Persistence with Hibernate, Second Edition
> >>> <http://www.manning.com/bauer3/>
> >>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> >>> Spring Batch in Action <http://www.manning.com/templier/>
> >>> Blog: http://garygregory.wordpress.com
> >>> Home: http://garygregory.com/
> >>> Tweet! http://twitter.com/GaryGregory
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >> For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
> > --
> > E-Mail: garydgregory@gmail.com | ggregory@apache.org
> > Java Persistence with Hibernate, Second Edition
> > <http://www.manning.com/bauer3/>
> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > Spring Batch in Action <http://www.manning.com/templier/>
> > Blog: http://garygregory.wordpress.com
> > Home: http://garygregory.com/
> > Tweet! http://twitter.com/GaryGregory
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message