Deleted Added
full compact
sftp-client.c (124208) sftp-client.c (126274)
1/*
1/*
2 * Copyright (c) 2001-2003 Damien Miller. All rights reserved.
2 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
3 *
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
12 *
7 *
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 */
24
25/* XXX: memleaks */
26/* XXX: signed vs unsigned */
27/* XXX: remove all logging, only return status codes */
28/* XXX: copy between two remote sites */
29
30#include "includes.h"
15 */
16
17/* XXX: memleaks */
18/* XXX: signed vs unsigned */
19/* XXX: remove all logging, only return status codes */
20/* XXX: copy between two remote sites */
21
22#include "includes.h"
31RCSID("$OpenBSD: sftp-client.c,v 1.44 2003/06/28 16:23:06 deraadt Exp $");
23RCSID("$OpenBSD: sftp-client.c,v 1.46 2004/02/17 05:39:51 djm Exp $");
32
33#include "openbsd-compat/sys-queue.h"
34
35#include "buffer.h"
36#include "bufaux.h"
37#include "getput.h"
38#include "xmalloc.h"
39#include "log.h"

--- 753 unchanged lines hidden (view full) ---

793 debug3("Sent message SSH2_FXP_OPEN I:%u P:%s", id, remote_path);
794
795 handle = get_handle(conn->fd_in, id, &handle_len);
796 if (handle == NULL) {
797 buffer_free(&msg);
798 return(-1);
799 }
800
24
25#include "openbsd-compat/sys-queue.h"
26
27#include "buffer.h"
28#include "bufaux.h"
29#include "getput.h"
30#include "xmalloc.h"
31#include "log.h"

--- 753 unchanged lines hidden (view full) ---

785 debug3("Sent message SSH2_FXP_OPEN I:%u P:%s", id, remote_path);
786
787 handle = get_handle(conn->fd_in, id, &handle_len);
788 if (handle == NULL) {
789 buffer_free(&msg);
790 return(-1);
791 }
792
801 local_fd = open(local_path, O_WRONLY | O_CREAT | O_TRUNC,
793 local_fd = open(local_path, O_WRONLY | O_CREAT | O_TRUNC,
802 mode | S_IWRITE);
803 if (local_fd == -1) {
804 error("Couldn't open local file \"%s\" for writing: %s",
805 local_path, strerror(errno));
806 buffer_free(&msg);
807 xfree(handle);
808 return(-1);
809 }

--- 131 unchanged lines hidden (view full) ---

941 status = -1;
942 do_close(conn, handle, handle_len);
943 } else {
944 status = do_close(conn, handle, handle_len);
945
946 /* Override umask and utimes if asked */
947#ifdef HAVE_FCHMOD
948 if (pflag && fchmod(local_fd, mode) == -1)
794 mode | S_IWRITE);
795 if (local_fd == -1) {
796 error("Couldn't open local file \"%s\" for writing: %s",
797 local_path, strerror(errno));
798 buffer_free(&msg);
799 xfree(handle);
800 return(-1);
801 }

--- 131 unchanged lines hidden (view full) ---

933 status = -1;
934 do_close(conn, handle, handle_len);
935 } else {
936 status = do_close(conn, handle, handle_len);
937
938 /* Override umask and utimes if asked */
939#ifdef HAVE_FCHMOD
940 if (pflag && fchmod(local_fd, mode) == -1)
949#else
941#else
950 if (pflag && chmod(local_path, mode) == -1)
951#endif /* HAVE_FCHMOD */
952 error("Couldn't set mode on \"%s\": %s", local_path,
953 strerror(errno));
954 if (pflag && (a->flags & SSH2_FILEXFER_ATTR_ACMODTIME)) {
955 struct timeval tv[2];
956 tv[0].tv_sec = a->atime;
957 tv[1].tv_sec = a->mtime;

--- 193 unchanged lines hidden ---
942 if (pflag && chmod(local_path, mode) == -1)
943#endif /* HAVE_FCHMOD */
944 error("Couldn't set mode on \"%s\": %s", local_path,
945 strerror(errno));
946 if (pflag && (a->flags & SSH2_FILEXFER_ATTR_ACMODTIME)) {
947 struct timeval tv[2];
948 tv[0].tv_sec = a->atime;
949 tv[1].tv_sec = a->mtime;

--- 193 unchanged lines hidden ---