diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2011-04-08 10:52:50 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2011-04-11 12:36:08 +0200 |
commit | 092ec16fdf5a8b7b4a094fdeb634c2359251052c (patch) | |
tree | 05f9e4c7677b1ae635c9003f0d2a1a2301cad98e | |
parent | 3f1ff6b730ec17ce635fcf38770358d8042e80b4 (diff) | |
download | barebox-092ec16fdf5a8b7b4a094fdeb634c2359251052c.tar.gz barebox-092ec16fdf5a8b7b4a094fdeb634c2359251052c.tar.xz |
fs: use safe_strncpy instead of sprintf
This is safe against string overflows.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | fs/fs.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -30,6 +30,7 @@ #include <xfuncs.h> #include <init.h> #include <module.h> +#include <libbb.h> void *read_file(const char *filename, size_t *size) { @@ -783,7 +784,7 @@ int mount(const char *device, const char *fsname, const char *_path) goto out; } } - sprintf(fsdev->dev.name, "%s", fsname); + safe_strncpy(fsdev->dev.name, fsname, MAX_DRIVER_NAME); fsdev->dev.type_data = fsdev; fsdev->dev.id = get_free_deviceid(fsdev->dev.name); @@ -807,7 +808,7 @@ int mount(const char *device, const char *fsname, const char *_path) /* add mtab entry */ entry = &fsdev->mtab; - sprintf(entry->path, "%s", path); + safe_strncpy(entry->path, path, PATH_MAX); entry->dev = dev; entry->parent_device = parent_device; entry->next = NULL; |