public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <Bart.VanAssche@wdc.com>
To: "hare@suse.de" <hare@suse.de>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>
Cc: "hch@lst.de" <hch@lst.de>,
	"james.bottomley@hansenpartnership.com"
	<james.bottomley@hansenpartnership.com>,
	Bart Van Assche <Bart.VanAssche@wdc.com>,
	"hare@suse.com" <hare@suse.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>
Subject: Re: [PATCHv5 2/5] scsi: Export blacklist flags to sysfs
Date: Tue, 26 Sep 2017 16:11:54 +0000	[thread overview]
Message-ID: <1506442313.27723.2.camel@wdc.com> (raw)
In-Reply-To: <1506060287-87031-3-git-send-email-hare@suse.de>

On Fri, 2017-09-22 at 08:04 +0200, Hannes Reinecke wrote:
> +static ssize_t
> +sdev_show_blacklist(struct device *dev, struct device_attribute *attr,
> +		    char *buf)
> +{

Please make this function accept the output buffer size as fourth argument.

> +		if (len)
> +			len += snprintf(buf + len, 2, " ");
> +
> +		if (name)
> +			len += snprintf(buf + len, strlen(name) + 1,
> +					"%s", name);
> +		else
> +			len += snprintf(buf + len, 67,
> +					"INVALID_BIT(%d)", i);
+	}
> +	if (len)
> +		len += snprintf(buf + len, 2, "\n");

Please adjust the snprintf() statements such that no buffer overflow can be
triggered.

Thanks,

Bart.

  parent reply	other threads:[~2017-09-26 16:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-22  6:04 [PATCHv5 0/5] scsi: Fixup blacklist handling Hannes Reinecke
2017-09-22  6:04 ` [PATCHv5 1/5] scsi_debug: allow to specify inquiry vendor and model Hannes Reinecke
2017-09-24 16:43   ` Douglas Gilbert
2017-09-22  6:04 ` [PATCHv5 2/5] scsi: Export blacklist flags to sysfs Hannes Reinecke
2017-09-23 23:22   ` kbuild test robot
2017-09-26 16:11   ` Bart Van Assche [this message]
2017-09-22  6:04 ` [PATCHv5 3/5] scsi_devinfo: Reformat blacklist flags Hannes Reinecke
2017-09-22  6:04 ` [PATCHv5 4/5] scsi_devinfo: Whitespace fixes Hannes Reinecke
2017-09-22  6:04 ` [PATCHv5 5/5] scsi_devinfo: fixup string compare Hannes Reinecke

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=1506442313.27723.2.camel@wdc.com \
    --to=bart.vanassche@wdc.com \
    --cc=hare@suse.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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