Return-Path: X-Original-To: apmail-logging-log4j-user-archive@www.apache.org Delivered-To: apmail-logging-log4j-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B9CE818C57 for ; Thu, 21 Jan 2016 02:21:48 +0000 (UTC) Received: (qmail 1592 invoked by uid 500); 21 Jan 2016 02:21:48 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 1540 invoked by uid 500); 21 Jan 2016 02:21:48 -0000 Mailing-List: contact log4j-user-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Users List" Reply-To: "Log4J Users List" Delivered-To: mailing list log4j-user@logging.apache.org Received: (qmail 1529 invoked by uid 99); 21 Jan 2016 02:21:48 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Jan 2016 02:21:48 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id EBF4018056D for ; Thu, 21 Jan 2016 02:21:47 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.9 X-Spam-Level: ** X-Spam-Status: No, score=2.9 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 590cUmz0IPuD for ; Thu, 21 Jan 2016 02:21:36 +0000 (UTC) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com [209.85.217.175]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id CBF8B20D77 for ; Thu, 21 Jan 2016 02:21:35 +0000 (UTC) Received: by mail-lb0-f175.google.com with SMTP id oh2so15546316lbb.3 for ; Wed, 20 Jan 2016 18:21:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=ZbS0KVq4cbmABkefk6haYjecRGss6hnV3At6ytDaDnk=; b=w0Rrc1QbZcoHAoJ0w5nGYvR0tUOh6pCgJAEiBj5FckLkgaM8gOJkY9gdDxs29ihe1B LBXZMXQR7z98N1K7bcS2fjU9VMPwr/VlTVG0v7nRjqyrGxohGDusA/YAm9XgsdZuPd1O TAJYeQQcz/7tZsVjlzvSBHu3eyv0Z+dnkrj7+nvuJ+RjJNv+gvP3VooviTDJt0hMr+DZ Bh0F6dHYDdRIN4JfZwaLh9l4FW3P0MAxj3Uqa7/AneTxT2js8DEZYx5nwZj3HeffPloC xLH+pvpqFmq57lcA3OAqUbJfwAp9tldYiq0ObR0GOKu6RSjYrPZM4+WPq66FyOF+L8G1 2z4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=ZbS0KVq4cbmABkefk6haYjecRGss6hnV3At6ytDaDnk=; b=Q0+gle682lIXYu0eQE3JY1ndNVXEWYxmyjVs/H2Rgub7TvniWnkpGOo9bdwFont/hr K5GDQwIfvJIhhLrHlPVN6ACzsF2GKTzjtnEMfar0q701htUvpR0a2zRuKt5MKHd9zArO rO9dMEEzbHNgaVFjBtuo7Fnl74zCHJjV2f5KsQ7/8LNWBzuw91DAZxLeiOp5WsICTXZ2 YJobTph7lGegj/mlqBezHPww0IBqZZoR/ECjzb77wrJNCxS1nDsODYNmClnHOx6ZfCpm 6d2BO8W3KRa6OdIlG2WHzb6QtN4l23QN5oQLn9t3Pfo7voLAPvoKTujGd9T0Mbfz9Xr4 9ovw== X-Gm-Message-State: AG10YOToE/y9nnff3dXz0yM4TXL2QRPEbtwCIJkW0/pdgaQqM07LrX+1+Fw+xSZKwSXq7zRh8VSBYEAJqvXUNg== MIME-Version: 1.0 X-Received: by 10.112.168.227 with SMTP id zz3mr7898946lbb.10.1453342894292; Wed, 20 Jan 2016 18:21:34 -0800 (PST) Received: by 10.112.200.201 with HTTP; Wed, 20 Jan 2016 18:21:34 -0800 (PST) In-Reply-To: References: <62FDFA39-3596-45C0-B1CC-D7677BCE5349@chewy.com> Date: Wed, 20 Jan 2016 18:21:34 -0800 Message-ID: Subject: Re: TlsSyslogFrame calculates message length incorrectly From: Gary Gregory To: Log4J Users List Content-Type: multipart/alternative; boundary=001a11c32c62f386ee0529cec2c8 --001a11c32c62f386ee0529cec2c8 Content-Type: text/plain; charset=UTF-8 On Wed, Jan 20, 2016 at 6:19 PM, Gary Gregory wrote: > I'm also wondering if the Layout should really be a String layout. > > This is smelly in TlsSyslogFrame: > > @Override > public String toString() { > final String length = Integer.toString(messageLengthInBytes); > return length + Chars.SPACE + message; > } > > combined with this in the Rfc5424 layout toSerializable(logEvent): > > if (useTlsMessageFormat) { > return new TlsSyslogFrame(buf.toString()).toString(); > } > > Which means that the size header is of variable length. Can that be right? > I guess that is OK since I now see the following in the spec: MSG-LEN = NONZERO-DIGIT *DIGIT G > > Gary > > On Wed, Jan 20, 2016 at 6:04 PM, Gary Gregory > 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 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 >> >> JUnit in Action, Second Edition >> Spring Batch in Action >> Blog: http://garygregory.wordpress.com >> Home: http://garygregory.com/ >> Tweet! http://twitter.com/GaryGregory >> > > > > -- > E-Mail: garydgregory@gmail.com | ggregory@apache.org > Java Persistence with Hibernate, Second Edition > > JUnit in Action, Second Edition > Spring Batch in Action > Blog: http://garygregory.wordpress.com > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory > -- E-Mail: garydgregory@gmail.com | ggregory@apache.org Java Persistence with Hibernate, Second Edition JUnit in Action, Second Edition Spring Batch in Action Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory --001a11c32c62f386ee0529cec2c8--