From: Steven Rostedt <rostedt@goodmis.org>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH v2] trace-cmd: Check all strdup() return values
Date: Sat, 3 Jun 2023 03:47:54 -0400 [thread overview]
Message-ID: <20230603034754.566d9fa6@rorschach.local.home> (raw)
In-Reply-To: <fdd6c91b-a1d2-3628-289f-b22e69f163ae@web.de>
On Sat, 3 Jun 2023 08:12:34 +0200
Markus Elfring <Markus.Elfring@web.de> wrote:
> …
> > +++ b/lib/trace-cmd/trace-input.c
> …
> > @@ -5967,9 +5974,10 @@ tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx)
> > new_handle->parent = handle;
> > new_handle->cpustats = NULL;
> > new_handle->hooks = NULL;
> > - if (handle->uname)
> > + if (handle->uname) {
> > /* Ignore if fails to malloc, no biggy */
> > new_handle->uname = strdup(handle->uname);
> > + }
> > tracecmd_ref(handle);
> >
> > new_handle->fd = dup(handle->fd);
>
> Does this return value ignorance need a bit more explanation?
Yes that should be checked.
>
>
> …
> > +++ b/tracecmd/trace-record.c
> …
> > @@ -6651,6 +6658,8 @@ static void parse_record_options(int argc,
> > case OPT_tsoffset:
> > cmd_check_die(ctx, CMD_set, *(argv+1), "--ts-offset");
> > ctx->date2ts = strdup(optarg);
> > + if (ctx->date2ts == NULL)
> > + die("Faield to allocate ts-offset");
> > if (ctx->data_flags & DATA_FL_DATE)
> > die("Can not use both --date and --ts-offset");
> > ctx->data_flags |= DATA_FL_OFFSET;
> > @@ -6712,6 +6721,8 @@ static void parse_record_options(int argc,
> > !tracecmd_compress_is_supported(optarg, NULL))
> > die("Compression algorithm %s is not supported", optarg);
> > ctx->compression = strdup(optarg);
> > + if (ctx->compression == NULL)
> > + die("Faield to allocate compression algorithm");
> > break;
> > case OPT_file_ver:
> > if (ctx->curr_cmd != CMD_record && ctx->curr_cmd != CMD_record_agent)
> …
> > +++ b/tracecmd/trace-split.c
> > @@ -367,6 +367,8 @@ static double parse_file(struct tracecmd_input *handle,
> > int fd;
> >
> > output = strdup(output_file);
> > + if (output == NULL)
> > + die("Faield to allocate output_file");
> > dir = dirname(output);
> > base = basename(output);
> >
> …
>
> I recommend to avoid typos also in error messages.
Heh, I'm pushing hard to get the trivial changes in so that I can start
working on some more substantial changes, and in the rush, I did make
some bad spelling mistakes. I will fix.
Thanks,
-- Steve
prev parent reply other threads:[~2023-06-03 7:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-03 3:01 [PATCH v2] trace-cmd: Check all strdup() return values Steven Rostedt
[not found] ` <fdd6c91b-a1d2-3628-289f-b22e69f163ae@web.de>
2023-06-03 7:47 ` Steven Rostedt [this message]
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=20230603034754.566d9fa6@rorschach.local.home \
--to=rostedt@goodmis.org \
--cc=Markus.Elfring@web.de \
--cc=linux-trace-devel@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 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).