From: Jani Nikula <jani.nikula@linux.intel.com>
To: "Ser, Simon" <simon.ser@intel.com>,
"igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>
Subject: Re: [igt-dev] [PATCH i-g-t] tests/testdisplay: fix heap overflow
Date: Wed, 20 Mar 2019 11:26:32 +0200 [thread overview]
Message-ID: <874l7xgalz.fsf@intel.com> (raw)
In-Reply-To: <f12816c03dbd699376fc974c0d16a14d07fc17c6.camel@intel.com>
On Wed, 20 Mar 2019, "Ser, Simon" <simon.ser@intel.com> wrote:
> We need to copy the terminating NULL byte too.
>
> Signed-off-by: Simon Ser <simon.ser@intel.com>
> ---
> tests/testdisplay.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/tests/testdisplay.c b/tests/testdisplay.c
> index b3657264..ff208384 100644
> --- a/tests/testdisplay.c
> +++ b/tests/testdisplay.c
> @@ -563,17 +563,17 @@ static gboolean input_event(GIOChannel *source,
> GIOCondition condition,
> return TRUE;
> }
>
> -static void enter_exec_path( char **argv )
> +static void enter_exec_path(char **argv)
> {
> char *exec_path = NULL;
> char *pos = NULL;
> short len_path = 0;
> int ret;
>
> - len_path = strlen( argv[0] );
> - exec_path = (char*) malloc(len_path);
> + len_path = strlen(argv[0]);
> + exec_path = (char*) malloc(len_path + 1);
>
> - memcpy(exec_path, argv[0], len_path);
> + memcpy(exec_path, argv[0], len_path + 1);
Ditch all of the above and replace with
exec_path = strdup(argv[0]);
BR,
Jani.
> pos = strrchr(exec_path, '/');
> if (pos != NULL)
> *(pos+1) = '\0';
--
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-03-20 9:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-20 7:43 [igt-dev] [PATCH i-g-t] tests/testdisplay: fix heap overflow Ser, Simon
2019-03-20 9:26 ` Jani Nikula [this message]
2019-03-20 9:29 ` Chris Wilson
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=874l7xgalz.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=simon.ser@intel.com \
/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