This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: string/test-memcpy error reporting
- From: "Ryan S. Arnold" <ryan dot arnold at gmail dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: libc-alpha <libc-alpha at sourceware dot org>
- Date: Tue, 13 Aug 2013 09:24:54 -0500
- Subject: Re: string/test-memcpy error reporting
- References: <20130809045828 dot GE3294 at bubble dot grove dot modra dot org>
On Thu, Aug 8, 2013 at 11:58 PM, Alan Modra <amodra@gmail.com> wrote:
> Using plain %s here runs the risk of segfaulting when displaying the
> string. src and dst aren't zero terminated strings.
>
> * string/test-memcpy.c (do_one_test): When reporting errors, print
> string address and don't overrun end of string.
>
> diff --git a/string/test-memcpy.c b/string/test-memcpy.c
> index d121ef0..b7ebe5f 100644
> --- a/string/test-memcpy.c
> +++ b/string/test-memcpy.c
> @@ -63,8 +63,8 @@ do_one_test (impl_t *impl, char *dst, const char *src,
>
> if (memcmp (dst, src, len) != 0)
> {
> - error (0, 0, "Wrong result in function %s dst \"%s\" src \"%s\"",
> - impl->name, dst, src);
> + error (0, 0, "Wrong result in function %s dst %p \"%.*s\" src %p \"%.*s\" len %zu",
> + impl->name, dst, (int) len, dst, src, (int) len, src, len);
> ret = 1;
> return;
> }
Seems like an obvious fix. Ack.
Ryan