From: Luiz Capitulino <lcapitulino@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: qemu-devel@nongnu.org, mst@redhat.com
Subject: [Qemu-devel] Re: [V3 PATCH] net: properly handle illegal fd/vhostfd from command line
Date: Mon, 25 Oct 2010 10:52:05 -0200 [thread overview]
Message-ID: <20101025105205.53167e32@doriath> (raw)
In-Reply-To: <20101025053959.10150.69081.stgit@dhcp-91-7.nay.redhat.com.englab.nay.redhat.com>
On Mon, 25 Oct 2010 13:39:59 +0800
Jason Wang <jasowang@redhat.com> wrote:
> When hanlding fd/vhostfd form command line through net_handle_fd_param(),
> we need to check mon and return value of strtol() otherwise we could
> get segmentation fault or invalid fd when user type an illegal fd/vhostfd.
>
> This patch is based on the suggestions from
> Luiz Capitulino <lcapitulino@redhat.com>.
>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
> net.c | 16 +++++++++++-----
> 1 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/net.c b/net.c
> index ed74c7f..c5e6063 100644
> --- a/net.c
> +++ b/net.c
> @@ -774,19 +774,25 @@ int qemu_find_nic_model(NICInfo *nd, const char * const *models,
>
> int net_handle_fd_param(Monitor *mon, const char *param)
> {
> - if (!qemu_isdigit(param[0])) {
> - int fd;
> + int fd;
> +
> + if (!qemu_isdigit(param[0]) && mon) {
>
> fd = monitor_get_fd(mon, param);
> if (fd == -1) {
> error_report("No file descriptor named %s found", param);
> return -1;
> }
> -
> - return fd;
> } else {
> - return strtol(param, NULL, 0);
> + char *endptr = NULL;
> +
> + fd = strtol(param, &endptr, 10);
> + if (*endptr || (fd == 0 && param == endptr)) {
> + return -1;
> + }
> }
> +
> + return fd;
> }
>
> static int net_init_nic(QemuOpts *opts,
>
next prev parent reply other threads:[~2010-10-25 12:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-25 5:39 [Qemu-devel] [V3 PATCH] net: properly handle illegal fd/vhostfd from command line Jason Wang
2010-10-25 12:52 ` Luiz Capitulino [this message]
2010-10-25 16:57 ` [Qemu-devel] " Michael S. Tsirkin
2010-10-26 14:58 ` Michael S. Tsirkin
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=20101025105205.53167e32@doriath \
--to=lcapitulino@redhat.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).