All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Carter <jwcart2@gmail.com>
To: HuaxinLu <luhuaxin1@foxmail.com>
Cc: SElinux list <selinux@vger.kernel.org>
Subject: Re: [PATCH] libsemanage: fix use-after-free in parse_module_store()
Date: Thu, 17 Jun 2021 13:42:45 -0400	[thread overview]
Message-ID: <CAP+JOzRjAoU2oRueyT6sPv9-xjVtjzhyxzXLuR6Pubd+-=R7jA@mail.gmail.com> (raw)
In-Reply-To: <tencent_90BF03402499B510C39EB8BC137D04294607@qq.com>

On Mon, Jun 14, 2021 at 12:52 AM HuaxinLu <luhuaxin1@foxmail.com> wrote:
>
> The passing parameter "arg" of parse_module_store will be freed after
> calling. A copy of parameter should be used instead of itself.
>
> Signed-off-by: HuaxinLu <luhuaxin1@foxmail.com>

Acked-by: James Carter <jwcart2@gmail.com>

> ---
>  libsemanage/src/conf-parse.y | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libsemanage/src/conf-parse.y b/libsemanage/src/conf-parse.y
> index 9bf9364a..eac91344 100644
> --- a/libsemanage/src/conf-parse.y
> +++ b/libsemanage/src/conf-parse.y
> @@ -516,12 +516,12 @@ static int parse_module_store(char *arg)
>                 char *s;
>                 current_conf->store_type = SEMANAGE_CON_POLSERV_REMOTE;
>                 if ((s = strchr(arg, ':')) == NULL) {
> -                       current_conf->store_path = arg;
> +                       current_conf->store_path = strdup(arg);
>                         current_conf->server_port = 4242;
>                 } else {
>                         char *endptr;
>                         *s = '\0';
> -                       current_conf->store_path = arg;
> +                       current_conf->store_path = strdup(arg);
>                         current_conf->server_port = strtol(s + 1, &endptr, 10);
>                         if (*(s + 1) == '\0' || *endptr != '\0') {
>                                 return -2;
> --
> 2.26.0
>

  reply	other threads:[~2021-06-17 17:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-14  4:21 [PATCH] libsemanage: fix use-after-free in parse_module_store() HuaxinLu
2021-06-17 17:42 ` James Carter [this message]
2021-06-18 14:50   ` Petr Lautrbach
2021-06-14  5:56 HuaxinLu

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='CAP+JOzRjAoU2oRueyT6sPv9-xjVtjzhyxzXLuR6Pubd+-=R7jA@mail.gmail.com' \
    --to=jwcart2@gmail.com \
    --cc=luhuaxin1@foxmail.com \
    --cc=selinux@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.