Changeset 10135fa in rtems


Ignore:
Timestamp:
Dec 20, 2018, 1:26:50 PM (6 months ago)
Author:
Thomas Dörfler <thomas.doerfler@…>
Branches:
master
Children:
2158621
Parents:
8af51b0
git-author:
Thomas Dörfler <thomas.doerfler@…> (12/20/18 13:26:50)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/21/18 06:50:47)
Message:

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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libnetworking/lib/tftpDriver.c

    r8af51b0 r10135fa  
    187187  const char *device = mt_entry->dev;
    188188  size_t devicelen = strlen (device);
    189   tftpfs_info_t *fs;
     189  tftpfs_info_t *fs = NULL;
    190190  char *root_path;
    191191
    192   if (devicelen == 0)
    193       rtems_set_errno_and_return_minus_one (ENXIO);
     192  if (devicelen == 0) {
     193    root_path = malloc (1);
     194    if (root_path == NULL)
     195      goto error;
     196    root_path [0] = '\0';
     197  }
     198  else {
     199    root_path = malloc (devicelen + 2);
     200    if (root_path == NULL)
     201      goto error;
     202
     203    root_path = memcpy (root_path, device, devicelen);
     204    root_path [devicelen] = '/';
     205    root_path [devicelen + 1] = '\0';
     206  }
    194207
    195208  fs = malloc (sizeof (*fs));
    196   root_path = malloc (devicelen + 2);
    197   if (root_path == NULL || fs == NULL)
    198       goto error;
    199 
    200   root_path = memcpy (root_path, device, devicelen);
    201   root_path [devicelen] = '/';
    202   root_path [devicelen + 1] = '\0';
    203 
     209  if (fs == NULL)
     210    goto error;
    204211  fs->flags = 0;
    205212  fs->nStreams = 0;
     
    539546     * Extract the host name component
    540547     */
     548    if (*full_path_name == '/')
     549      full_path_name++;
     550
    541551    hostname = full_path_name;
    542552    cp1 = strchr (full_path_name, ':');
Note: See TracChangeset for help on using the changeset viewer.