From: Chen Gang <gang.chen@asianux.com>
To: Mauro Carvalho Chehab <mchehab@redhat.com>, josephdanielwalter@gmail.com
Cc: Greg KH <gregkh@linuxfoundation.org>,
linux-media@vger.kernel.org,
"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>
Subject: [PATCH] staging: strncpy issue, need always let NUL terminated string ended by zero.
Date: Tue, 07 May 2013 20:11:08 +0800 [thread overview]
Message-ID: <5188EF5C.3030003@asianux.com> (raw)
For NUL terminated string, need always let it ended by zero.
The 'name' may be copied to user mode ('dvb_fe->ops.info' is 'struct
dvb_frontend_info' which is defined in ./include/uapi/...), and its
length is also known within as102_dvb_register_fe(), so need fully
initialize it (not use strlcpy instead of strncpy).
Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
drivers/staging/media/as102/as102_fe.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/media/as102/as102_fe.c b/drivers/staging/media/as102/as102_fe.c
index 9ce8c9d..b3efec9 100644
--- a/drivers/staging/media/as102/as102_fe.c
+++ b/drivers/staging/media/as102/as102_fe.c
@@ -334,6 +334,7 @@ int as102_dvb_register_fe(struct as102_dev_t *as102_dev,
memcpy(&dvb_fe->ops, &as102_fe_ops, sizeof(struct dvb_frontend_ops));
strncpy(dvb_fe->ops.info.name, as102_dev->name,
sizeof(dvb_fe->ops.info.name));
+ dvb_fe->ops.info.name[sizeof(dvb_fe->ops.info.name) - 1] = '\0';
/* register dvb frontend */
errno = dvb_register_frontend(dvb_adap, dvb_fe);
--
1.7.7.6
next reply other threads:[~2013-05-07 12:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-07 12:11 Chen Gang [this message]
2013-05-21 11:47 ` [PATCH] staging: strncpy issue, need always let NUL terminated string ended by zero Mauro Carvalho Chehab
2013-05-21 11:53 ` Chen Gang
2013-06-08 4:35 ` Chen Gang
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=5188EF5C.3030003@asianux.com \
--to=gang.chen@asianux.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=josephdanielwalter@gmail.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.