9
0
Fork 0

fs: use safe_strncpy instead of sprintf

This is safe against string overflows.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2011-04-08 10:52:50 +02:00
parent 3f1ff6b730
commit 092ec16fdf
1 changed files with 3 additions and 2 deletions

View File

@ -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;