From owner-freebsd-dtrace@FreeBSD.ORG Wed Sep 18 13:34:47 2013 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 589B7A82; Wed, 18 Sep 2013 13:34:47 +0000 (UTC) (envelope-from freebsd-listen@fabiankeil.de) Received: from smtprelay01.ispgateway.de (smtprelay01.ispgateway.de [80.67.18.43]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 17D0B2B09; Wed, 18 Sep 2013 13:34:46 +0000 (UTC) Received: from [78.35.157.165] (helo=fabiankeil.de) by smtprelay01.ispgateway.de with esmtpsa (SSLv3:AES128-SHA:128) (Exim 4.68) (envelope-from ) id 1VMHnM-0005eH-7s; Wed, 18 Sep 2013 15:27:52 +0200 Date: Wed, 18 Sep 2013 15:19:12 +0200 From: Fabian Keil To: Mark Johnston Subject: Re: pr_psargs on FreeBSD Message-ID: <5e28d134.49bf1edd@fabiankeil.de> In-Reply-To: <20130915221622.GA2981@raichu> References: <20130915221622.GA2981@raichu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/1=JbcjTFsUTqjTHqYcnOBU1"; protocol="application/pgp-signature" X-Df-Sender: Nzc1MDY3 Cc: dtrace-discuss@lists.dtrace.org, freebsd-dtrace@freebsd.org X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Sep 2013 13:34:47 -0000 --Sig_/1=JbcjTFsUTqjTHqYcnOBU1 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Mark Johnston wrote: > It's kind of a strong-armed approach, but the problem's been around for a > while and I can't think of any clever solutions - I'd love to see an > alternative solution. >=20 > My patch against FreeBSD (pasted below) adds a function called memstr() > to DTrace. memstr() takes three arguments: addr, c, and len, and returns > a copy of addr of length len with all null-terminators replaced by c, > and with the last byte replaced by a null-terminator. In particular, > memstr() always returns a string of length len - 1, unless len =3D=3D 0, = in > which case we return the empty string. [...] > and execsnoop works properly. Any thoughts on this function? Have I missed > a better solution? A patch for FreeBSD is below. Looks good (and clever) to me and seems to work as expected. Thanks a lot. I briefly looked into this a couple of months ago and was under the impression that it would require a lot more code ... Fabian --Sig_/1=JbcjTFsUTqjTHqYcnOBU1 Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.21 (FreeBSD) iEYEARECAAYFAlI5qE8ACgkQBYqIVf93VJ2gjgCglcTYYrq47+tzbIkHxKb5r1wK n0cAniU/bnpvEzYZZfOks505a39Z/Gfy =x+E/ -----END PGP SIGNATURE----- --Sig_/1=JbcjTFsUTqjTHqYcnOBU1--