From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] lib: fix offset in tst_resm_hexd
Date: Mon, 16 Jan 2017 10:26:59 +0100 [thread overview]
Message-ID: <20170116092659.GA20956@rei.lan> (raw)
In-Reply-To: <fa1847cc72ff0178bd6744a1822077674059af28.1484300599.git.jstancek@redhat.com>
Hi!
> Commit f72ca5b9c484 "lib: add tst_res_hexd for newlib"
> broke tst_resm_hexd when I moved "offset = strlen(tmesg)"
> before macro that expands varargs.
>
> Fix it by moving offset initialisation after EXPAND_VAR_ARGS.
>
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
> ---
> lib/tst_res.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lib/tst_res.c b/lib/tst_res.c
> index 261dec0fbba8..61daaeb4944e 100644
> --- a/lib/tst_res.c
> +++ b/lib/tst_res.c
> @@ -509,7 +509,7 @@ void tst_resm_hexd_(const char *file, const int lineno, int ttype,
> char tmesg[USERMESG];
> static const size_t symb_num = 2; /* xx */
> static const size_t size_max = 16;
> - size_t offset = strlen(tmesg);
> + size_t offset;
> size_t i;
> char *pmesg = tmesg;
> tst_res_func_t res_func;
> @@ -520,6 +520,7 @@ void tst_resm_hexd_(const char *file, const int lineno, int ttype,
> res_func = tst_res__;
>
> EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG);
> + offset = strlen(tmesg);
>
> if (size > size_max || size == 0 ||
> (offset + size * (symb_num + 1)) >= USERMESG)
Good catch. Thanks for fixing this, acked.
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2017-01-16 9:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-13 9:45 [LTP] [PATCH] lib: fix offset in tst_resm_hexd Jan Stancek
2017-01-16 9:26 ` Cyril Hrubis [this message]
2017-01-16 13:33 ` Jan Stancek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170116092659.GA20956@rei.lan \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox