summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan Maxwell <dylan.maxwell@lightsource.ca>2012-12-06 09:48:16 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-12-06 09:50:20 +0100
commitd29f20620930cdd36a129f8784bf98c707bfdfc5 (patch)
tree8f4fde168c0d8633b2208a6f153ea37e19e4d127
parentRemove stray '/'. (diff)
downloadrtems-d29f20620930cdd36a129f8784bf98c707bfdfc5.tar.bz2
tftpfs: PR1624: Fix parsing of hostnames and paths
-rw-r--r--cpukit/libnetworking/lib/tftpDriver.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/cpukit/libnetworking/lib/tftpDriver.c b/cpukit/libnetworking/lib/tftpDriver.c
index 2b25f264e3..bbaf493fd3 100644
--- a/cpukit/libnetworking/lib/tftpDriver.c
+++ b/cpukit/libnetworking/lib/tftpDriver.c
@@ -574,8 +574,12 @@ static int rtems_tftp_open_worker(
*/
hostname = full_path_name;
cp1 = strchr (full_path_name, ':');
- if (!cp1)
+ if (!cp1) /* if can't use : as delimiter, try / */
+ cp1 = strchr (full_path_name, '/');
+ if (!cp1) {
hostname = "BOOTP_HOST";
+ cp1 = full_path_name;
+ }
else {
*cp1 = '\0';
++cp1;
@@ -591,8 +595,6 @@ static int rtems_tftp_open_worker(
if (he == NULL)
return ENOENT;
memcpy (&farAddress, he->h_addr, sizeof (farAddress));
- } else {
- return ENOENT;
}
/*
@@ -784,11 +786,9 @@ static int rtems_tftp_open(
*/
device =
rtems_filesystem_mount_device (rtems_filesystem_location_mount (&iop->pathinfo));
- dlen = strlen (device);
- if (dlen == 0)
- rtems_set_errno_and_return_minus_one (ENOENT);
+ dlen = device ? strlen(device) : 0;
- if (iop->pathinfo.node_access_2 == NULL)
+ if (iop->pathinfo.node_access == NULL || iop->pathinfo.node_access_2 == NULL)
rtems_set_errno_and_return_minus_one (ENOENT);
if (iop->pathinfo.node_access != ROOT_NODE_ACCESS (fs)) {
@@ -824,7 +824,10 @@ static int rtems_tftp_open(
full_path_name = malloc (dlen + nalen + sep1 + na2len + 1);
if (full_path_name == NULL)
rtems_set_errno_and_return_minus_one(ENOMEM);
- strcpy (full_path_name, device);
+ if (dlen)
+ strcpy (full_path_name, device);
+ else
+ strcpy (full_path_name, "");
if (nalen)
strcat (full_path_name, na);
if (sep1)