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:04:19 GMT
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

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