Separate search may delete files with no warning

Bug reports will be moved here when the described bug has been fixed

Moderators: sheep, Hacker, Stefan2, white

User avatar
DrShark
Power Member
Power Member
Posts: 1569
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262

Separate search may delete files with no warning

Post by *DrShark »

It's possible to start separate search in 2 ways: first way is to use cm_SearchStandalone command, second way is to use a command line parameters passed to total commander executable (may be useful if started with custom wincmd.ini parameter e.g. to disable some wcx packers for search in archives):
%COMMANDER_EXE% /I=customwincmd.ini /S=F

If filename or filenames are passed after that command, they go to "Search in:" field of separate search. However, TC may delete files if their filenames are passed using %P%S or %p%s parameter.

To reproduce (don't try it on important data!):
1. Select some files, like zip archives (it seems at least 2 selected names needed to cause a bug).
2. Paste a button:

Code: Select all

TOTALCMD#BAR#DATA
%COMMANDER_EXE% /S=F
?%p%s
wcmicons.dll,47



-1
and start it.
You'll see a dialog to confirm filenames passed to separate search.
As passed by %p%s, this format is different from one used by "Search in:" Find Files field (there is no ; separator), so I added ? before %p%s to edit paths/names list in text editor before passing to Find Files.
However, to reproduce the bug, we just confirm names as they appear by default in that dialog.
Separate Find Files window appear then while at least one of selected files (it seems usually last one) will be permanently deleted (no remove to Recycle bin!) without delete confirmation warning!

Edit: removed unnecessary reproduce step 3 (see Ovg's comment).
Last edited by DrShark on 2018-04-09, 08:03 UTC, edited 2 times in total.
Android 4.3.1 no root, kernel 08.09.2016; Vista Home Premium SP2 rus 32 bit
TC #149847 Personal licence

Cuz we're all in this together, We're here to make it right

User avatar
Horst.Epp
Power Member
Power Member
Posts: 3760
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post by *Horst.Epp »

Confirmed
Windows 10 Home x64 May 2020 Update, Version 2004 (OS Build 19041.331)
Intel(R) Core(TM) i7-4770 CPU @ 3.40GH, 16GB RAM
TC 9.51 x64 / x86, Everything 1.4.1.984 (x64)

User avatar
Ovg
Power Member
Power Member
Posts: 647
Joined: 2014-01-06, 16:26 UTC
Location: MOW

Post by *Ovg »

Even there is no need in step 3: the last selected file is deleted at the start of Separate Find Files.
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 9.51 x64, Windows 7 SP1 x64

User avatar
HolgerK
Power Member
Power Member
Posts: 5221
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

Hmm, isn't it a self-made bug, to use such a parameter combination which is not mentioned in the help?

First parameter after "/S=F:.." seems to be the base directory of the search.
Second parameter "/R=%TEMP%\<randomname>.tmp" seems to be a temporary list files which holds the marked folders, files where to search in.
Of course this temp file has to be removed after usage (expected behavior).

One may say that it would be more secure for users like DrShark if this should only happen if it is preluded with "/R="...

On the other hand: Why do you use %P%S in this place after reading the help?

Regards
Holger
Make our planet great again

User avatar
Horst.Epp
Power Member
Power Member
Posts: 3760
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post by *Horst.Epp »

HolgerK wrote:Hmm, isn't it a self-made bug, to use such a parameter combination which is not mentioned in the help?

First parameter after "/S=F:.." seems to be the base directory of the search.
Second parameter "/R=%TEMP%\<randomname>.tmp" seems to be a temporary list files which holds the marked folders, files where to search in.
Of course this temp file has to be removed after usage (expected behavior).

One may say that it would be more secure for users like DrShark if this should only happen if it is preluded with "/R="...

On the other hand: Why do you use %P%S in this place after reading the help?

Regards
Holger
There is no temp file explicitly given as parameter in my tests.
And regardless of how its used
TC should never delete an Archive I give as an arg in searches.
Windows 10 Home x64 May 2020 Update, Version 2004 (OS Build 19041.331)
Intel(R) Core(TM) i7-4770 CPU @ 3.40GH, 16GB RAM
TC 9.51 x64 / x86, Everything 1.4.1.984 (x64)

User avatar
DrShark
Power Member
Power Member
Posts: 1569
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262

Post by *DrShark »

HolgerK wrote:First parameter after "/S=F:.." seems to be the base directory of the search.
Second parameter "/R=%TEMP%\<randomname>.tmp" seems to be a temporary list files which holds the marked folders, files where to search in.

Why do you use %P%S in this place after reading the help?
Command line parameters Help page says nothing about a parameter which is a name of a file that must be deleted:
TC 9.12 Help, [u]Command line parameters[/u] page wrote:...Parameters:

Drive:\Directory Loads the first directory passed to Total Commander into the left window, and the second into the right window. Directory names containing spaces must be put in double quotes! Always specify the full path name including the drive!
/O If Total Commander is already running, activate it and pass the path(s) in the command line to that instance (overrides the settings in the configuration dialog to have multiple windows)
...
/R= will be interpreted as the target dir.
...
/S=F Open "Find Files" dialog without TC main window, e.g. totalcmd.exe /S=F "c:\start path"
Accepts additional parameters separated by a colon, e.g. /S=F:S1Lname
    S Sort results by: 1=name, 2=extension, 3=size, 4=date/time. Negative value for descending order
    L<x> As LAST parameter: Load search with name <x>, e.g. "/S=F:Lmax 1 day old"[/b]
...
/O=list_name Only combined with /S=S: Passes list file for function "Only selected (in main window)", e.g. /O=%F
/T Opens the passed dir(s) in new tab(s). Now also works when Total Commander hasn't been open yet.
...
2Ovg
I can confirm it, thanks, first post is corrected now.
Android 4.3.1 no root, kernel 08.09.2016; Vista Home Premium SP2 rus 32 bit
TC #149847 Personal licence

Cuz we're all in this together, We're here to make it right

User avatar
HolgerK
Power Member
Power Member
Posts: 5221
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

DrShark wrote:Command line parameters Help page says nothing about a parameter which is a name of a file that must be deleted:
TC 9.12 Help, [u]Command line parameters[/u] page wrote:...Parameters:
/S=F Open "Find Files" dialog without TC main window, e.g. totalcmd.exe /S=F "c:\start path"
Accepts additional parameters separated by a colon, e.g. /S=F:S1Lname
    S Sort results by: 1=name, 2=extension, 3=size, 4=date/time. Negative value for descending order
    L<x> As LAST parameter: Load search with name <x>, e.g. "/S=F:Lmax 1 day old"
Yes, but help also says nothing about that you can use a list of filenames as optional parameter (%p%s)....

It's simply my observation of the command line arguments (with ProcessExplorer) if you start a separate search using cm_SearchStandalone.

Regards
Holger
Make our planet great again

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 39728
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

It's not really a bug - the second path parameter passed to the search is the name of the temporary file with the list of selected files. This was added recently, and therefore apparently not documented. I will add a check that the name ends with .tmp, otherwise I will ignore the parameter.
Author of Total Commander
http://www.ghisler.com

User avatar
DrShark
Power Member
Power Member
Posts: 1569
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262

Post by *DrShark »

ghisler(Author) wrote:I will add a check that the name ends with .tmp, otherwise I will ignore the parameter.
Thanks!
Android 4.3.1 no root, kernel 08.09.2016; Vista Home Premium SP2 rus 32 bit
TC #149847 Personal licence

Cuz we're all in this together, We're here to make it right

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 39728
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

TC 9.20 beta 1 now only deletes the file if the name ends with .tmp, please test it!
Author of Total Commander
http://www.ghisler.com

User avatar
Ovg
Power Member
Power Member
Posts: 647
Joined: 2014-01-06, 16:26 UTC
Location: MOW

Post by *Ovg »

2ghisler(Author)
Confirmed!
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 9.51 x64, Windows 7 SP1 x64

User avatar
DrShark
Power Member
Power Member
Posts: 1569
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262

Post by *DrShark »

history920.txt wrote:09.04.18 Fixed: Separate search dialog: only use second file name as list file name (selected files) if the name ends with .tmp (32/64)
I can also confirm the fix on TC+Vista 32-bit.
Android 4.3.1 no root, kernel 08.09.2016; Vista Home Premium SP2 rus 32 bit
TC #149847 Personal licence

Cuz we're all in this together, We're here to make it right

User avatar
DrShark
Power Member
Power Member
Posts: 1569
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262

Re: Separate search may delete files with no warning

Post by *DrShark »

ghisler(Author) wrote:
2018-05-04, 08:08 UTC
TC 9.20 beta 1 now only deletes the file if the name ends with .tmp, please test it!
history920.txt wrote:09.04.18 Fixed: Separate search dialog: only use second file name as list file name (selected files) if the name ends with .tmp (32/64)
In TC 9.50 there is an addition for temp files created by Total Commander:
history950.txt wrote:27.01.19 Added: Set flag FILE_ATTRIBUTE_TEMPORARY when unpacking to TEMP, e.g. when searching or comparing by content (32/64)
Since TC now should set FILE_ATTRIBUTE_TEMPORARY to temporary files made by itself, may it be a way to distinguish temp filelist passed to Separate search natively by TC and by .tmp files passed to separate search as a second parameter using a button (as one in bugreport example)? If yes, maybe it's possible to change the 9.20 bugfix so will delete only *.tmp with FILE_ATTRIBUTE_TEMPORARY set, and won't touch other *.tmp if such passed via button?

2petermad Re: OT - joking
thanks, fixed the typo. I prefer not to use spell checkers, even those without auto correction, unless I'm typing some very important text, so when I have some time I'm re-reading my text to find and fix typos manually: this way it's easier to remember the right spelling, at least for me.
Last edited by DrShark on 2019-11-18, 06:22 UTC, edited 1 time in total.
Android 4.3.1 no root, kernel 08.09.2016; Vista Home Premium SP2 rus 32 bit
TC #149847 Personal licence

Cuz we're all in this together, We're here to make it right

User avatar
petermad
Power Member
Power Member
Posts: 9661
Joined: 2003-02-05, 20:24 UTC
Location: Valsted, Denmark
Contact:

OT - joking

Post by *petermad »

---filelist passed to Separate search naively by TC...
So now TC is naive ;-)
License #524
Danish Total Commander Translator
TC 9.51 32+64bit on Win XP 32bit, Win 7, 8.1 & 10 (1909) 64bit, 'Everything' 1.4.1.965 (x64)
TC 3.0 on Android 6.0
Get:
Extended Total Commander Menus | TC Languagebar | TC Dark Help | PHSM-Calendar

User avatar
DrShark
Power Member
Power Member
Posts: 1569
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262

Re: Separate search may delete files with no warning

Post by *DrShark »

I got a reply by email:
Christian Ghisler wrote:That would be unreliable. FILE_ATTRIBUTE_TEMPORARY only seems to work with NTFS drives. I can't just check whether the file system is NTFS, because Linux drives will also report NTFS, although they are EXT4 or so.
So the only reliable way is to detect whether really temporary list is passed as the second parameter to %COMMANDER_EXE% /S=F is to check whole parameters line for presence of /R=%TEMP%\<randomlistname> in it, and it would allow TC not to remove random *.tmp files passed to %COMMANDER_EXE% /S=F as a second parameter WITHOUT /R switch. I know such command line check is not implemented in TC 9.20 because the functions used to check the command line parameters passed to %COMMANDER_EXE% are quite complex and placed in different parts of TC code. So is there a chance to see proper fix which will allow TC to delete only file lists passed after /R parameter?
Android 4.3.1 no root, kernel 08.09.2016; Vista Home Premium SP2 rus 32 bit
TC #149847 Personal licence

Cuz we're all in this together, We're here to make it right

Post Reply