summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Dörfler <thomas.doerfler@embedded-brains.de>2018-12-20 14:26:50 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-12-21 07:50:47 +0100
commit10135fab5d94fb856e07cdf0c80fd476399f5ed2 (patch)
treed8c749833ff8152075215527d0c23e053845f872
parentpsxhdrs: Changing copyright license to BSD-2-Clause (diff)
downloadrtems-10135fab5d94fb856e07cdf0c80fd476399f5ed2.tar.bz2
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
-rw-r--r--cpukit/libnetworking/lib/tftpDriver.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/cpukit/libnetworking/lib/tftpDriver.c b/cpukit/libnetworking/lib/tftpDriver.c
index 514f931b13..7cbb402b63 100644
--- a/cpukit/libnetworking/lib/tftpDriver.c
+++ b/cpukit/libnetworking/lib/tftpDriver.c
@@ -186,21 +186,28 @@ int rtems_tftpfs_initialize(
{
const char *device = mt_entry->dev;
size_t devicelen = strlen (device);
- tftpfs_info_t *fs;
+ tftpfs_info_t *fs = NULL;
char *root_path;
- if (devicelen == 0)
- rtems_set_errno_and_return_minus_one (ENXIO);
-
- fs = malloc (sizeof (*fs));
- root_path = malloc (devicelen + 2);
- if (root_path == NULL || fs == NULL)
+ if (devicelen == 0) {
+ root_path = malloc (1);
+ if (root_path == NULL)
+ goto error;
+ root_path [0] = '\0';
+ }
+ else {
+ root_path = malloc (devicelen + 2);
+ if (root_path == NULL)
goto error;
- root_path = memcpy (root_path, device, devicelen);
- root_path [devicelen] = '/';
- root_path [devicelen + 1] = '\0';
+ root_path = memcpy (root_path, device, devicelen);
+ root_path [devicelen] = '/';
+ root_path [devicelen + 1] = '\0';
+ }
+ fs = malloc (sizeof (*fs));
+ if (fs == NULL)
+ goto error;
fs->flags = 0;
fs->nStreams = 0;
fs->tftpStreams = 0;
@@ -538,6 +545,9 @@ static int rtems_tftp_open_worker(
/*
* Extract the host name component
*/
+ if (*full_path_name == '/')
+ full_path_name++;
+
hostname = full_path_name;
cp1 = strchr (full_path_name, ':');
if (!cp1) {