From: jeremie.galarneau@efficios.com (Jérémie Galarneau)
Subject: [lttng-dev] [PATCH lttng-tools 1/2] Fix: pids should be numbers only
Date: Tue, 28 Jul 2015 11:51:06 -0400 [thread overview]
Message-ID: <CA+jJMxss0H3ZpkneDY9XAgehYnzi5DBRCEQoGs=E5WCFfVJa5w@mail.gmail.com> (raw)
In-Reply-To: <1437774180-32746-1-git-send-email-jonathan.rajotte-julien@efficios.com>
Merged, thanks!
J/r/mie
On Fri, Jul 24, 2015 at 5:42 PM, Jonathan Rajotte <
jonathan.rajotte-julien at efficios.com> wrote:
> Ruled out cases: word, number+word, word+number, number+word+number
> Ex: foo, 123foo, foo123, 123foo123
>
> Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien at efficios.com>
> ---
> src/bin/lttng/commands/track-untrack.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/src/bin/lttng/commands/track-untrack.c
> b/src/bin/lttng/commands/track-untrack.c
> index 52442cc..639e184 100644
> --- a/src/bin/lttng/commands/track-untrack.c
> +++ b/src/bin/lttng/commands/track-untrack.c
> @@ -96,6 +96,7 @@ int parse_pid_string(const char *_pid_string,
> int count = 0;
> int *pid_list = NULL;
> char *pid_string = NULL;
> + char *endptr;
>
> if (all && _pid_string) {
> ERR("An empty PID string is expected with --all");
> @@ -132,13 +133,16 @@ int parse_pid_string(const char *_pid_string,
> while (one_pid_str != NULL) {
> unsigned long v;
>
> - v = strtoul(one_pid_str, NULL, 10);
> + errno = 0;
> + v = strtoul(one_pid_str, &endptr, 10);
> if ((v == 0 && errno == EINVAL)
> - || (v == ULONG_MAX && errno == ERANGE)) {
> + || (v == ULONG_MAX && errno == ERANGE)
> + || (*one_pid_str != '\0' && *endptr !=
> '\0')){
> ERR("Error parsing PID %s", one_pid_str);
> retval = CMD_ERROR;
> goto error;
> }
> +
> if ((long) v > INT_MAX || (int) v < 0) {
> ERR("Invalid PID value %ld", (long) v);
> retval = CMD_ERROR;
> --
> 2.1.4
>
>
--
J?r?mie Galarneau
EfficiOS Inc.
http://www.efficios.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20150728/9e8a345a/attachment.html>
prev parent reply other threads:[~2015-07-28 15:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-24 21:42 Jonathan Rajotte
2015-07-24 21:43 ` [lttng-dev] [PATCH lttng-tools 2/2] Fix: do not spawn sessiond on track/untrack commands Jonathan Rajotte
2015-07-27 15:42 ` Jérémie Galarneau
2015-07-28 15:51 ` Jérémie Galarneau [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='CA+jJMxss0H3ZpkneDY9XAgehYnzi5DBRCEQoGs=E5WCFfVJa5w@mail.gmail.com' \
--to=jeremie.galarneau@efficios.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