Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kgudipat@brocade.com
Cc: linux-scsi@vger.kernel.org
Subject: re: [SCSI] bfa: Add support to read/update the FRU data.
Date: Thu, 11 Oct 2012 09:57:29 +0300	[thread overview]
Message-ID: <20121011065729.GE31607@elgon.mountain> (raw)

Hello Krishna Gudipati,

The patch e6826c96ced7: "[SCSI] bfa: Add support to read/update the 
FRU data." from Sep 21, 2012, leads to the following warning:
drivers/scsi/bfa/bfad_bsg.c:114 bfad_iocmd_ioc_get_info()
	 error: buffer overflow 'iocmd->adapter_hwpath' 32 <= 32

diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c
index 0ab1d40..555e7db 100644
--- a/drivers/scsi/bfa/bfad_bsg.c
+++ b/drivers/scsi/bfa/bfad_bsg.c
@@ -107,9 +107,10 @@ bfad_iocmd_ioc_get_info(struct bfad_s *bfad, void *cmd)
 
        /* set adapter hw path */
        strcpy(iocmd->adapter_hwpath, bfad->pci_name);
-       i = strlen(iocmd->adapter_hwpath) - 1;
-       while (iocmd->adapter_hwpath[i] != '.')
-               i--;
+       for (i = 0; iocmd->adapter_hwpath[i] != ':' && i < BFA_STRING_32; i++)
+               ;

i is 32 here.

+       for (; iocmd->adapter_hwpath[++i] != ':' && i < BFA_STRING_32; )
+               ;

i is 33 after the increment.

        iocmd->adapter_hwpath[i] = '\0';

We are placing a NUL char 2 places past the end of the array.

        iocmd->status = BFA_STATUS_OK;
        return 0;

regards,
dan carpenter


                 reply	other threads:[~2012-10-11  6:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20121011065729.GE31607@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=kgudipat@brocade.com \
    --cc=linux-scsi@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