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 3264A18CFE for ; Thu, 21 Jan 2016 02:38:08 +0000 (UTC) Received: (qmail 41380 invoked by uid 500); 21 Jan 2016 02:38:07 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 41333 invoked by uid 500); 21 Jan 2016 02:38:07 -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 41321 invoked by uid 99); 21 Jan 2016 02:38:07 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Jan 2016 02:38:07 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 66B41C0CC4 for ; Thu, 21 Jan 2016 02:38:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.799 X-Spam-Level: X-Spam-Status: No, score=0.799 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id F3vRUr8Maeq2 for ; Thu, 21 Jan 2016 02:37:56 +0000 (UTC) Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0126.outbound.protection.outlook.com [207.46.100.126]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 40B9420D0D for ; Thu, 21 Jan 2016 02:37:56 +0000 (UTC) Received: from CY1PR07MB2118.namprd07.prod.outlook.com (10.164.73.156) by CY1PR07MB2120.namprd07.prod.outlook.com (10.164.73.158) with Microsoft SMTP Server (TLS) id 15.1.365.19; Thu, 21 Jan 2016 02:37:47 +0000 Received: from CY1PR07MB2118.namprd07.prod.outlook.com ([10.164.73.156]) by CY1PR07MB2118.namprd07.prod.outlook.com ([10.164.73.156]) with mapi id 15.01.0365.024; Thu, 21 Jan 2016 02:37:47 +0000 From: Blake Day To: Log4J Users List Subject: Re: TlsSyslogFrame calculates message length incorrectly Thread-Topic: TlsSyslogFrame calculates message length incorrectly Thread-Index: AQHRU+bKKaAaU/R7LUa8wSC/7N07XZ8FOEWAgAAD4SGAAAPiAIAAAZgm Date: Thu, 21 Jan 2016 02:37:47 +0000 Message-ID: References: <62FDFA39-3596-45C0-B1CC-D7677BCE5349@chewy.com> <474383BE-9BC3-4D73-A259-225932A5AEB9@chewy.com>, In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=blake@chewy.com; x-originating-ip: [70.193.212.194] x-microsoft-exchange-diagnostics: 1;CY1PR07MB2120;5:r9vsasB4bM2lfRzD7vcpJIivzg/STAAM7UgtK5hR3vGeRmRuyfGMzFauOX7wlpHViaMa7FZdhqg131PkggT6U4Rx2rYXelww+B9dl68kVtEBFxL6nW+EgtiMwWAckblR4Vo0ZtOJwsfJpbIEmE+seA==;24:fTx+N1JN2e40BQ6PFcur0MC+BhzZhtBFUeItiYULs4ptUFzaWu2np+LsMRVESszg++E10DXrlFRNYsDXSZWA1uS8WGRX3RBH/NGflsKRHp8= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(42134001)(42139001);SRVR:CY1PR07MB2120; x-ms-office365-filtering-correlation-id: bc539097-d0f8-47f9-e31c-08d3220bd97c x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(117838167249255); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(3002001)(10201501046);SRVR:CY1PR07MB2120;BCL:0;PCL:0;RULEID:;SRVR:CY1PR07MB2120; x-forefront-prvs: 08286A0BE2 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(199003)(189002)(252514010)(24454002)(377454003)(15395725005)(82746002)(33656002)(93886004)(86362001)(66066001)(99286002)(54356999)(122556002)(50986999)(76176999)(40100003)(101416001)(2950100001)(19580405001)(19580395003)(2420400006)(36756003)(1096002)(1220700001)(586003)(3846002)(102836003)(106116001)(587094005)(450100001)(10710500007)(11100500001)(6116002)(16601075003)(106356001)(5004730100002)(5002640100001)(5008740100001)(1720100001)(105586002)(87936001)(83716003)(325944007)(77096005)(5001960100002)(15975445007)(2906002)(97736004)(10400500002)(189998001)(2900100001)(107886002)(110136002)(92566002)(81156007)(7110500001)(104396002)(569784001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR07MB2120;H:CY1PR07MB2118.namprd07.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: chewy.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: chewy.com X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2016 02:37:47.6165 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 99879b8e-3b16-427d-902a-05eda342f629 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2120 I'm mobile so can't confirm, but utf-8 has multi-byte characters as well. > On Jan 20, 2016, at 9:32 PM, Gary Gregory wrote: >=20 >> On Wed, Jan 20, 2016 at 6:18 PM, Blake Day wrote: >>=20 >> I'm not sure on that, but it wouldn't fix the erroneous byte count on lo= g >> messages with a multi-byte unicode character. >=20 > Please see my latest message. >=20 > "multi-byte unicode character." Doesn't the spec call for UTF-8 as the on= ly > encoding? >=20 > Gary >=20 >=20 >>>> On Jan 20, 2016, at 9:04 PM, Gary Gregory >>> wrote: >>>=20 >>> Hm, shouldn't we be using UTF-8 instead of Charset.defaultCharset() in: >>>=20 >>> public byte[] getBytes() { >>> final String frame =3D toString(); >>> return frame.getBytes(Charset.defaultCharset()); >>> } >>>=20 >>> ? >>>=20 >>> Gary >>>=20 >>>> On Wed, Jan 20, 2016 at 4:58 PM, Blake Day wrote: >>>>=20 >>>> 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. >>>>=20 >>>> See below for relevant portions of code: >>>>=20 >>>> private String message; >>>> private int messageLengthInBytes; >>>>=20 >>>> private void setLengthInBytes() { >>>> messageLengthInBytes =3D message.length(); >>>> } >>>>=20 >>>> @Override >>>> public String toString() { >>>> final String length =3D Integer.toString(messageLengthInBytes); >>>> return length + Chars.SPACE + message; >>>> } >>>>=20 >>>>=20 >>>>=20 >>>>=20 >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org >>>> For additional commands, e-mail: log4j-user-help@logging.apache.org >>>=20 >>>=20 >>> -- >>> 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 >>=20 >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org >> For additional commands, e-mail: log4j-user-help@logging.apache.org >=20 >=20 > --=20 > 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 --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-user-help@logging.apache.org