From: "Tobin C. Harding" <me@tobin.cc>
To: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
noralf@tronnes.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
"Tobin C. Harding" <me@tobin.cc>
Subject: [PATCH v2 3/3] staging: fbtft: Add check on strlcpy() return value
Date: Wed, 15 Feb 2017 14:27:25 +1100 [thread overview]
Message-ID: <1487129245-24970-4-git-send-email-me@tobin.cc> (raw)
In-Reply-To: <1487129245-24970-1-git-send-email-me@tobin.cc>
Return value of strlcpy() is not checked. Name string is silently
truncated if longer that SPI_NAME_SIZE, whilst not detrimental to
the program logic it would be nice to notify the user. Module is
currently quite verbose, adding extra pr_warn() calls will not overly
impact this verbosity.
Check return value from call to strlcpy(). If source string is
truncated call pr_warn() to notify user.
Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
drivers/staging/fbtft/fbtft_device.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c
index 5fbdd37..78baf46 100644
--- a/drivers/staging/fbtft/fbtft_device.c
+++ b/drivers/staging/fbtft/fbtft_device.c
@@ -1483,7 +1483,13 @@ static int __init fbtft_device_init(void)
displays[i].pdev->name = name;
displays[i].spi = NULL;
} else {
- strlcpy(displays[i].spi->modalias, name, SPI_NAME_SIZE);
+ size_t len;
+
+ len = strlcpy(displays[i].spi->modalias, name,
+ SPI_NAME_SIZE);
+ if (len >= SPI_NAME_SIZE)
+ pr_warn("modalias (name) truncated to: %s\n",
+ displays[i].spi->modalias);
displays[i].pdev = NULL;
}
}
--
2.7.4
prev parent reply other threads:[~2017-02-15 3:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-15 3:27 [PATCH v2 0/3] staging: fbtft: Fix buffer overflow vulnerability Tobin C. Harding
2017-02-15 3:27 ` [PATCH v2 1/3] " Tobin C. Harding
2017-02-15 3:27 ` [PATCH v2 2/3] staging: fbtft: Replace magic number with constant Tobin C. Harding
2017-02-15 3:36 ` Joe Perches
2017-02-15 3:27 ` Tobin C. Harding [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=1487129245-24970-4-git-send-email-me@tobin.cc \
--to=me@tobin.cc \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=noralf@tronnes.org \
--cc=thomas.petazzoni@free-electrons.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