Patchwork [U-Boot] fs:fat: fix set file name function

login
register
mail settings
Submitter Piotr Wilczek
Date Oct. 11, 2013, 1:43 p.m.
Message ID <1381499013-32138-1-git-send-email-p.wilczek@samsung.com>
Download mbox | patch
Permalink /patch/282761/
State Accepted
Delegated to: Tom Rini
Headers show

Comments

Piotr Wilczek - Oct. 11, 2013, 1:43 p.m.
Curently memcpy copies string without null terminating char because
function strlen returns only number of characters excluding
null terminating character. Replace memcpy with strcpy.

Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Tom Rini <trini@ti.com>
---
 fs/fat/fat_write.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Tom Rini - Nov. 8, 2013, 10:27 p.m.
On Fri, Oct 11, 2013 at 03:43:33PM +0200, Piotr Wilczek wrote:

> Curently memcpy copies string without null terminating char because
> function strlen returns only number of characters excluding
> null terminating character. Replace memcpy with strcpy.
> 
> Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> CC: Tom Rini <trini@ti.com>

Applied to u-boot/master, thanks!

Patch

diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index b7a21e0..9f5e911 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -57,7 +57,7 @@  static void set_name(dir_entry *dirent, const char *filename)
 	if (len == 0)
 		return;
 
-	memcpy(s_name, filename, len);
+	strcpy(s_name, filename);
 	uppercase(s_name, len);
 
 	period = strchr(s_name, '.');