When memory management goes bad...
ReWolf (ReWolf) <rewolfrewolfpl> Thursday, March 4 2010 13:00.59 CST


Few months ago I've encountered a strange behavior in cmd.exe when I wanted to list some big collection of files and execute some command on every single file. I used for this task 'for' command similar to this:

for /R c:\ %c in (*.*) do echo %c >> cmd_ptc.log

After few hours of processing I get a very disturbing message:

"Not enough storage is available to process this command."

Actually cmd.exe can eat all memory available for the process. I decided to check why it needs such amount of memory and if it will be possible fix it. Below you can find link to the full article and package with the fixed binaries (from Windows Vista SP2):

http://rewolf.pl/stuff/rewolf_cmd_research.pdf - article
http://rewolf.pl/stuff/rewolf_cmd_research.zip - article and binaries

Happy reading !
ReWolf

Comments
bw Posted: Thursday, March 4 2010 13:10.36 CST
&#8211; Feb 2009 &#8211; discovered problem
&#8211; Jul 2009 &#8211; researched and patched cmd.exe
&#8211; Mar 2010 &#8211; finished this paper

damn, you're one, lazy bum :)

GynvaelColdwind Posted: Thursday, March 4 2010 13:37.51 CST
Great paper! I've really enjoyed the way you've explained how you traced and fixed the leak issue :)
It's a perfect paper to show to reverse engineering students and say "please look here... yes, this is how you should do it".
Thanks for sharing ;>

MFox Posted: Thursday, March 4 2010 14:19.49 CST
really detailed.

tnx!

sovietskicpu Posted: Saturday, March 6 2010 12:47.13 CST
Rewolf, great job as usual ;)
GynvaelColdwind, dear friend how are you doing ? :) hope you'll enjoy Dubai hehe..  

petroleum Posted: Saturday, March 6 2010 15:42.41 CST
Thanks rewolf, very interesting!!

GynvaelColdwind Posted: Sunday, March 7 2010 12:07.09 CST
@sovietskicpu
Hey :) Long time no chat my firend (and our last vm-detection related chat was very educating, so I kinda miss new ones ;<) ;>
Any chance seeing you in Dubai? It would be great to meet openrce guys in person ;)

Orr Posted: Monday, March 8 2010 04:45.05 CST
Impressive!  
The scale and the ambition of your work were executed professionally.


frankboldewin Posted: Tuesday, April 6 2010 13:22.18 CDT
thanx dude! very good reading.