From: Thomas Dörfler <thomas.doerf...@embedded-brains.de> 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 --- cpukit/libnetworking/lib/tftpDriver.c | 30 ++++++++++++++++++++---------- 1 file 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) { -- 2.16.4 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel