Changeset e6f4a612 in rtems


Ignore:
Timestamp:
Mar 16, 2015, 7:28:20 PM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
a7c7bdc
Parents:
72d3f1a6
git-author:
Sebastian Huber <sebastian.huber@…> (03/16/15 19:28:20)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/17/15 15:18:03)
Message:

IMFS: NUL-terminate name returned by readdir()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libfs/src/imfs/imfs_dir_default.c

    r72d3f1a6 re6f4a612  
    2020#include "imfs.h"
    2121
     22#include <sys/param.h>
    2223#include <dirent.h>
    2324#include <string.h>
     
    7475         dir_ent->d_reclen = sizeof( *dir_ent );
    7576         dir_ent->d_ino = IMFS_node_to_ino( imfs_node );
    76          dir_ent->d_namlen = imfs_node->namelen;
    77          memcpy( dir_ent->d_name, imfs_node->name, dir_ent->d_namlen + 1 );
     77         dir_ent->d_namlen =
     78           MIN( imfs_node->namelen, sizeof( dir_ent->d_name ) - 1 );
     79         dir_ent->d_name[ dir_ent->d_namlen ] = '\0';
     80         memcpy( dir_ent->d_name, imfs_node->name, dir_ent->d_namlen );
    7881
    7982         iop->offset += sizeof( *dir_ent );
Note: See TracChangeset for help on using the changeset viewer.