* [PATCH] ASoC: soc-core: Replace use of strncpy() with strlcpy()
@ 2010-12-06 15:42 Dimitris Papastamos
2010-12-06 19:16 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Dimitris Papastamos @ 2010-12-06 15:42 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood; +Cc: alsa-devel, patches
By using strncpy() if the source string does not have a null byte in the
first n bytes, then the destination string is not null-terminated.
This can be fixed in a two-step process by manually null-terminating the
array after the use of strncpy() or by using strlcpy().
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
---
sound/soc/soc-core.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index fd284a7..e586616 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3202,7 +3202,7 @@ static inline char *fmt_single_name(struct device *dev, int *id)
if (dev_name(dev) == NULL)
return NULL;
- strncpy(name, dev_name(dev), NAME_SIZE);
+ strlcpy(name, dev_name(dev), NAME_SIZE);
/* are we a "%s.%d" name (platform and SPI components) */
found = strstr(name, dev->driver->name);
@@ -3225,7 +3225,7 @@ static inline char *fmt_single_name(struct device *dev, int *id)
/* sanitize component name for DAI link creation */
snprintf(tmp, NAME_SIZE, "%s.%s", dev->driver->name, name);
- strncpy(name, tmp, NAME_SIZE);
+ strlcpy(name, tmp, NAME_SIZE);
} else
*id = 0;
}
--
1.7.3.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ASoC: soc-core: Replace use of strncpy() with strlcpy()
2010-12-06 15:42 [PATCH] ASoC: soc-core: Replace use of strncpy() with strlcpy() Dimitris Papastamos
@ 2010-12-06 19:16 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2010-12-06 19:16 UTC (permalink / raw)
To: Dimitris Papastamos; +Cc: alsa-devel, patches, Liam Girdwood
On Mon, Dec 06, 2010 at 03:42:17PM +0000, Dimitris Papastamos wrote:
> By using strncpy() if the source string does not have a null byte in the
> first n bytes, then the destination string is not null-terminated.
> This can be fixed in a two-step process by manually null-terminating the
> array after the use of strncpy() or by using strlcpy().
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-12-06 19:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-06 15:42 [PATCH] ASoC: soc-core: Replace use of strncpy() with strlcpy() Dimitris Papastamos
2010-12-06 19:16 ` Mark Brown
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.