forked from Imagelibrary/rtems
tftpfs: Some bug fixes
Fix for: - tftpfs did not mount, when device field in mount entry is empty - tftpfs needs to allocate fs structure before it fills it (avoid use of uninitialized pointer) - tftpfs needs to skip initial slash before hostname
This commit is contained in:
committed by
Sebastian Huber
parent
8af51b09e2
commit
10135fab5d
@@ -186,21 +186,28 @@ int rtems_tftpfs_initialize(
|
|||||||
{
|
{
|
||||||
const char *device = mt_entry->dev;
|
const char *device = mt_entry->dev;
|
||||||
size_t devicelen = strlen (device);
|
size_t devicelen = strlen (device);
|
||||||
tftpfs_info_t *fs;
|
tftpfs_info_t *fs = NULL;
|
||||||
char *root_path;
|
char *root_path;
|
||||||
|
|
||||||
if (devicelen == 0)
|
if (devicelen == 0) {
|
||||||
rtems_set_errno_and_return_minus_one (ENXIO);
|
root_path = malloc (1);
|
||||||
|
if (root_path == NULL)
|
||||||
fs = malloc (sizeof (*fs));
|
goto error;
|
||||||
root_path = malloc (devicelen + 2);
|
root_path [0] = '\0';
|
||||||
if (root_path == NULL || fs == NULL)
|
}
|
||||||
|
else {
|
||||||
|
root_path = malloc (devicelen + 2);
|
||||||
|
if (root_path == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
root_path = memcpy (root_path, device, devicelen);
|
root_path = memcpy (root_path, device, devicelen);
|
||||||
root_path [devicelen] = '/';
|
root_path [devicelen] = '/';
|
||||||
root_path [devicelen + 1] = '\0';
|
root_path [devicelen + 1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
fs = malloc (sizeof (*fs));
|
||||||
|
if (fs == NULL)
|
||||||
|
goto error;
|
||||||
fs->flags = 0;
|
fs->flags = 0;
|
||||||
fs->nStreams = 0;
|
fs->nStreams = 0;
|
||||||
fs->tftpStreams = 0;
|
fs->tftpStreams = 0;
|
||||||
@@ -538,6 +545,9 @@ static int rtems_tftp_open_worker(
|
|||||||
/*
|
/*
|
||||||
* Extract the host name component
|
* Extract the host name component
|
||||||
*/
|
*/
|
||||||
|
if (*full_path_name == '/')
|
||||||
|
full_path_name++;
|
||||||
|
|
||||||
hostname = full_path_name;
|
hostname = full_path_name;
|
||||||
cp1 = strchr (full_path_name, ':');
|
cp1 = strchr (full_path_name, ':');
|
||||||
if (!cp1) {
|
if (!cp1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user