Bug 1771

Summary: sftp heap memory leak
Product: Portable OpenSSH Reporter: Anicka Bernathova <anicka>
Component: sftpAssignee: Assigned to nobody <unassigned-bugs>
Status: CLOSED FIXED    
Severity: normal CC: djm
Priority: P2    
Version: 5.5p1   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 1708    
Attachments:
Description Flags
fix for sftp memory leak none

Description Anicka Bernathova 2010-05-15 00:53:31 AEST
Created attachment 1849 [details]
fix for sftp memory leak

sftp client has a memory leak, steps to reproduce:
1. echo "" | awk '{for(i=0; i <1000000;i++) print "-cd an_not_exist_directory"}' > sftp.cmd (run on server)
2. sftp -b sftp.cmd root@server (run on client)
3. watch heap growing (ie. "pmap pid | grep heap" on Linux):

555555668000 441368K 441368K 441368K rw-p [heap]
555555668000 468480K 468464K 468464K rw-p [heap]
555555668000 486600K 486484K 486484K rw-p [heap]
555555668000 657764K 657764K 657764K rw-p [heap]
555555668000 699912K 699912K 699912K rw-p [heap]
555555668000 751312K 751260K 751260K rw-p [heap]
555555668000 788448K 788448K 788448K rw-p [heap]
555555668000 838304K 838188K 838188K rw-p [heap]
555555668000 916176K 916176K 916176K rw-p [heap]
555555668000 946888K 946876K 946876K rw-p [heap]
555555668000 972972K 972960K 972960K rw-p [heap]
555555668000 995076K 995076K 995076K rw-p [heap]
555555668000 1021032K 1020940K 1020940K rw-p [heap]
555555668000 1044804K 1044804K 1044804K rw-p [heap]
555555668000 1337784K 1337784K 1337784K rw-p [heap]
555555668000 1389828K 1389828K 1389828K rw-p [heap]

I am attaching patch that fixes the problem.
Comment 1 Damien Miller 2010-06-18 14:43:37 AEST
Fix applied, this will be in OpenSSH-5.6. Thanks for the nice testcase and patch.
Comment 2 Damien Miller 2011-01-24 12:33:38 AEDT
Move resolved bugs to CLOSED after 5.7 release