dir_data->current_directory

Using TestDisk to undelete files
Forum rules
When asking for technical support:
- Search for posts on the same topic before posting a new question.
- Give clear, specific information in the title of your post.
- Include as many details as you can, MOST POSTS WILL GET ONLY ONE OR TWO ANSWERS.
- Post a follow up with a "Thank you" or "This worked!"
- When you learn something, use that knowledge to HELP ANOTHER USER LATER.
Before posting, please read https://www.cgsecurity.org/testdisk.pdf
Post Reply
Message
Author
mesajflaviu
Posts: 25
Joined: 12 Sep 2019, 19:54

dir_data->current_directory

#1 Post by mesajflaviu » 27 Nov 2019, 15:57

I have tried to trace the value of dir_data->current_directory from dir_whole_partition_log_aux function. And I noticed that this variable could have file names too, not only directory names ... I have done something wrong here ?

Code: Select all

int dir_whole_partition_log_aux(disk_t* disk, const partition_t* partition, dir_data_t* dir_data, const unsigned long int inode)
{
...
....
	td_list_for_each(file_walker, &dir_list.list)
	{
		const file_info_t* current_file = td_list_entry_const(file_walker, const file_info_t, list);
		if (LINUX_S_ISDIR(current_file->st_mode) != 0 &&
			is_inode_valid(current_file, dir_nbr, inode_known) > 0 &&
			strlen(dir_data->current_directory) + 1 + strlen(current_file->name) < sizeof(dir_data->current_directory) - 1)
		{
			TRACE("%s\n", dir_data->current_directory);		// here I could have files or folders ?
			if (strcmp(dir_data->current_directory, "/"))
				strcat(dir_data->current_directory, "/");
			strcat(dir_data->current_directory, current_file->name);
			dir_whole_partition_log_aux(disk, partition, dir_data, current_file->st_ino);
			/* restore current_directory name */
			dir_data->current_directory[current_directory_namelength] = '\0';
		}
	}
...
...
}


Sponsored links

User avatar
cgrenier
Site Admin
Posts: 4989
Joined: 18 Feb 2012, 15:08
Location: Le Perreux Sur Marne, France
Contact:

Re: dir_data->current_directory

#2 Post by cgrenier » 28 Nov 2019, 06:51

The variable is truncated to remove the filename part before exiting the function:

Code: Select all

/* restore current_directory name */
dir_data->current_directory[current_directory_namelength] = '\0';

Post Reply