lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Thu, 17 Oct 2019 07:46:03 +0800
From:   Qu Wenruo <quwenruo.btrfs@....com>
To:     Steven Rostedt <rostedt@...dmis.org>, Qu Wenruo <wqu@...e.com>
Cc:     linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-trace-devel@...r.kernel.org
Subject: Re: [PATCH] tools/lib/traceevent, perf tools: Handle %pU format
 correctly



On 2019/10/16 下午10:54, Steven Rostedt wrote:
> On Wed, 16 Oct 2019 14:39:20 +0800
> Qu Wenruo <wqu@...e.com> wrote:
> 
>> +static void print_uuid_arg(struct trace_seq *s, void *data, int size,
>> +			   struct tep_event *event, struct tep_print_arg *arg)
>> +{
>> +	const char *fmt;
>> +	unsigned char *buf;
>> +
>> +	fmt = "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x";
>> +	if (arg->type != TEP_PRINT_FIELD) {
>> +		trace_seq_printf(s, "ARG TYPE NOT FIELID but %d", arg->type);
>> +		return;
>> +	}
>> +
>> +	if (!arg->field.field) {
>> +		arg->field.field = tep_find_any_field(event, arg->field.name);
>> +		if (!arg->field.field) {
>> +			do_warning("%s: field %s not found",
>> +				   __func__, arg->field.name);
>> +			return;
>> +		}
>> +	}
>> +	buf = data + arg->field.field->offset;
> 
> You also need to make sure the data field is not smaller than 16 bytes.
> 
> 	if (arg->field.field->size < 16) {
> 		trace_seq_puts(s, "INVALIDUUID");
> 		return;
> 	}
> 

Oh, forgot that sanity check.

>> +
>> +	trace_seq_printf(s, fmt, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
>> +		         buf[6], buf[7], buf[8], buf[9], buf[10], buf[11], buf[12],
>> +			 buf[13], buf[14], buf[15]);
>> +}
>> +
> 
> Hmm, I know print_mac_addr() does something similar as this, but this
> is getting a bit extreme (too many arguments!). What about doing:
> 
> 	for (i = 0; i < 4; i++)
> 		trace_seq_printf(s, "%02x", buf++);
> 
> 	for (i = 0; i < 3; i++)
> 		trace_seq_printf(s, "-%02x%02x", buf[i * 2], buf[i * 2 + 1]);
> 
> 	buf += 6;
> 
> 	trace_seq_putc(s, '-');
> 
> 	for (i = 0; i < 6; i++)
> 		trace_seq_printf(s, "%02x", buf++);
> 
> 
> 
> Hmm, not sure the above is better, but having that many arguments just
> looks ugly to me.

Indeed, I'll update the patchset to make it more sane.

Thanks,
Qu
> 
> -- Steve
> 



Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ