Linux CXL
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: Li Zhijian <lizhijian@fujitsu.com>
Cc: nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org,
	Dave Jiang <dave.jiang@intel.com>
Subject: Re: [ndctl PATCH v4 3/4] ndctl: use strcmp for reserved word in monitor commands
Date: Tue, 11 Jul 2023 10:58:11 -0700	[thread overview]
Message-ID: <ZK2YM7nlCrEmz1+9@aschofie-mobl2> (raw)
In-Reply-To: <20230711115344.562823-4-lizhijian@fujitsu.com>

On Tue, Jul 11, 2023 at 07:53:43PM +0800, Li Zhijian wrote:
> According to the tool's documentation, when '-l standard' is specified,
> log would be output to the stdout. But since it's using strncmp(a, b, 10)
> to compare the former 10 characters, it will also wrongly detect a filename
> starting with a substring 'standard' as stdout.
> 
> For example:
> $ cxl monitor -l standard.log
> 
> User is most likely want to save log to ./standard.log instead of stdout.

Reviewed-by: Alison Schofield <alison.schofield@intel.com>

> 
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
> ---
> V4: combine ndctl/monitor to one patch
> V3: Improve commit log # Dave
> V2: commit log updated # Dave
> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
> ---
>  cxl/monitor.c   | 2 +-
>  ndctl/monitor.c | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/cxl/monitor.c b/cxl/monitor.c
> index e83455b63d35..a85452a4dc82 100644
> --- a/cxl/monitor.c
> +++ b/cxl/monitor.c
> @@ -188,7 +188,7 @@ int cmd_monitor(int argc, const char **argv, struct cxl_ctx *ctx)
>  	else
>  		monitor.ctx.log_priority = LOG_INFO;
>  
> -	if (strncmp(log, "./standard", 10) == 0)
> +	if (strcmp(log, "./standard") == 0)
>  		monitor.ctx.log_fn = log_standard;
>  	else {
>  		monitor.ctx.log_file = fopen(log, "a+");
> diff --git a/ndctl/monitor.c b/ndctl/monitor.c
> index 89903def63d4..bd8a74863476 100644
> --- a/ndctl/monitor.c
> +++ b/ndctl/monitor.c
> @@ -610,9 +610,9 @@ int cmd_monitor(int argc, const char **argv, struct ndctl_ctx *ctx)
>  	if (monitor.log) {
>  		if (strncmp(monitor.log, "./", 2) != 0)
>  			fix_filename(prefix, (const char **)&monitor.log);
> -		if (strncmp(monitor.log, "./syslog", 8) == 0)
> +		if (strcmp(monitor.log, "./syslog") == 0)
>  			monitor.ctx.log_fn = log_syslog;
> -		else if (strncmp(monitor.log, "./standard", 10) == 0)
> +		else if (strcmp(monitor.log, "./standard") == 0)
>  			monitor.ctx.log_fn = log_standard;
>  		else {
>  			monitor.ctx.log_file = fopen(monitor.log, "a+");
> -- 
> 2.29.2
> 

  reply	other threads:[~2023-07-11 17:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-11 11:53 [ndctl PATCH v4 0/4] cxl/monitor and ndctl/monitor fixes Li Zhijian
2023-07-11 11:53 ` [ndctl PATCH v4 1/4] cxl/monitor: Enable default_log and refactor sanity check Li Zhijian
2023-07-11 17:57   ` Alison Schofield
2023-07-11 11:53 ` [ndctl PATCH v4 2/4] cxl/monitor: replace monitor.log_file with monitor.ctx.log_file Li Zhijian
2023-07-11 17:57   ` Alison Schofield
2023-07-11 11:53 ` [ndctl PATCH v4 3/4] ndctl: use strcmp for reserved word in monitor commands Li Zhijian
2023-07-11 17:58   ` Alison Schofield [this message]
2023-07-11 11:53 ` [ndctl PATCH v4 4/4] Documentation/cxl/cxl-monitor.txt: Fix inaccurate description Li Zhijian
2023-07-11 17:58   ` Alison Schofield

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=ZK2YM7nlCrEmz1+9@aschofie-mobl2 \
    --to=alison.schofield@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=lizhijian@fujitsu.com \
    --cc=nvdimm@lists.linux.dev \
    /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