summaryrefslogtreecommitdiff
path: root/sftp-server.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2003-03-10 11:21:17 +1100
committerDamien Miller <djm@mindrot.org>2003-03-10 11:21:17 +1100
commit0011138d47e284273ba77415f7162aaab60d9a44 (patch)
treec175bfc5d470a641dfc727490eec5765903992d2 /sftp-server.c
parent73942b9d54ec71ae76e58d5bf3b06f094bfc3002 (diff)
- (djm) OpenBSD CVS Sync
- markus@cvs.openbsd.org 2003/03/05 22:33:43 [channels.c monitor.c scp.c session.c sftp-client.c sftp-int.c] [sftp-server.c ssh-add.c sshconnect2.c] fix memory leaks; from dlheine@suif.Stanford.EDU/CLOUSEAU; ok djm@
Diffstat (limited to 'sftp-server.c')
-rw-r--r--sftp-server.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sftp-server.c b/sftp-server.c
index 4eb31d94e..0c00003f8 100644
--- a/sftp-server.c
+++ b/sftp-server.c
@@ -22,7 +22,7 @@
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24#include "includes.h" 24#include "includes.h"
25RCSID("$OpenBSD: sftp-server.c,v 1.39 2003/02/06 09:29:18 markus Exp $"); 25RCSID("$OpenBSD: sftp-server.c,v 1.40 2003/03/05 22:33:43 markus Exp $");
26 26
27#include "buffer.h" 27#include "buffer.h"
28#include "bufaux.h" 28#include "bufaux.h"
@@ -158,7 +158,7 @@ handle_new(int use, char *name, int fd, DIR *dirp)
158 handles[i].use = use; 158 handles[i].use = use;
159 handles[i].dirp = dirp; 159 handles[i].dirp = dirp;
160 handles[i].fd = fd; 160 handles[i].fd = fd;
161 handles[i].name = name; 161 handles[i].name = xstrdup(name);
162 return i; 162 return i;
163 } 163 }
164 } 164 }
@@ -230,9 +230,11 @@ handle_close(int handle)
230 if (handle_is_ok(handle, HANDLE_FILE)) { 230 if (handle_is_ok(handle, HANDLE_FILE)) {
231 ret = close(handles[handle].fd); 231 ret = close(handles[handle].fd);
232 handles[handle].use = HANDLE_UNUSED; 232 handles[handle].use = HANDLE_UNUSED;
233 xfree(handles[handle].name);
233 } else if (handle_is_ok(handle, HANDLE_DIR)) { 234 } else if (handle_is_ok(handle, HANDLE_DIR)) {
234 ret = closedir(handles[handle].dirp); 235 ret = closedir(handles[handle].dirp);
235 handles[handle].use = HANDLE_UNUSED; 236 handles[handle].use = HANDLE_UNUSED;
237 xfree(handles[handle].name);
236 } else { 238 } else {
237 errno = ENOENT; 239 errno = ENOENT;
238 } 240 }
@@ -396,7 +398,7 @@ process_open(void)
396 if (fd < 0) { 398 if (fd < 0) {
397 status = errno_to_portable(errno); 399 status = errno_to_portable(errno);
398 } else { 400 } else {
399 handle = handle_new(HANDLE_FILE, xstrdup(name), fd, NULL); 401 handle = handle_new(HANDLE_FILE, name, fd, NULL);
400 if (handle < 0) { 402 if (handle < 0) {
401 close(fd); 403 close(fd);
402 } else { 404 } else {
@@ -681,7 +683,7 @@ process_opendir(void)
681 if (dirp == NULL) { 683 if (dirp == NULL) {
682 status = errno_to_portable(errno); 684 status = errno_to_portable(errno);
683 } else { 685 } else {
684 handle = handle_new(HANDLE_DIR, xstrdup(path), 0, dirp); 686 handle = handle_new(HANDLE_DIR, path, 0, dirp);
685 if (handle < 0) { 687 if (handle < 0) {
686 closedir(dirp); 688 closedir(dirp);
687 } else { 689 } else {