summaryrefslogtreecommitdiffstats
path: root/src/ntfs_dir.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2012-12-08 18:01:42 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2012-12-08 18:01:42 +0100
commitda6fe469c456e92aa4460b97a692fdd64b90043f (patch)
tree87072dbe21f9d5efe6d037b2e56b2a80b0233453 /src/ntfs_dir.c
parent4ab4b390670703606b43791b2a03e3cbc1d56378 (diff)
Windows: workaround for NTFS Alternate Data Stream creation
fopen() creates normal files instead of ADS with ':' replaced by an UTF char replace ':' by '_' instead
Diffstat (limited to 'src/ntfs_dir.c')
-rw-r--r--src/ntfs_dir.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/ntfs_dir.c b/src/ntfs_dir.c
index ebbc05e..8c012e9 100644
--- a/src/ntfs_dir.c
+++ b/src/ntfs_dir.c
@@ -180,9 +180,8 @@ static int ntfs_td_list_entry( struct ntfs_dir_struct *ls, const ntfschar *name
const int name_len, const int name_type, const s64 pos,
const MFT_REF mref, const unsigned dt_type)
{
- char *filename = NULL;
int result = 0;
- filename = (char *)calloc (1, MAX_PATH);
+ char *filename = (char *)calloc (1, MAX_PATH);
if (!filename)
{
log_critical("ntfs_td_list_entry calloc failed\n");
@@ -369,7 +368,7 @@ static int ntfs_copy(disk_t *disk_car, const partition_t *partition, dir_data_t
FILE *f_out;
s64 offset;
u32 block_size;
- const char *stream_name=NULL;
+ char *stream_name;
buffer = (char *)MALLOC(bufsize);
if (!buffer)
{
@@ -407,7 +406,20 @@ static int ntfs_copy(disk_t *disk_car, const partition_t *partition, dir_data_t
block_size = index_get_size(inode);
else
block_size = 0;
+#if defined(__CYGWIN__) || defined(__MINGW32__)
+ if(stream_name)
+ {
+ /* fopen() create normal files instead of ADS with ':' replaced by an UTF char
+ * replace ':' by '_' instead */
+ stream_name--;
+ *stream_name='_';
+ f_out=fopen_local(&new_file, dir_data->local_dir, dir_data->current_directory);
+ }
+ else
+ f_out=fopen_local(&new_file, dir_data->local_dir, dir_data->current_directory);
+#else
f_out=fopen_local(&new_file, dir_data->local_dir, dir_data->current_directory);
+#endif
if(!f_out)
{
log_critical("Can't create file %s: %s\n",new_file, strerror(errno));