|
|
9a9eba |
From 4d827f0d75a53d3952288ab882efbddea7ffadfe Mon Sep 17 00:00:00 2001
|
|
|
9a9eba |
From: "djm@openbsd.org" <djm@openbsd.org>
|
|
|
9a9eba |
Date: Tue, 4 Apr 2017 00:24:56 +0000
|
|
|
9a9eba |
Subject: [PATCH] upstream commit
|
|
|
9a9eba |
|
|
|
9a9eba |
disallow creation (of empty files) in read-only mode;
|
|
|
9a9eba |
reported by Michal Zalewski, feedback & ok deraadt@
|
|
|
9a9eba |
|
|
|
9a9eba |
Upstream-ID: 5d9c8f2fa8511d4ecf95322994ffe73e9283899b
|
|
|
9a9eba |
---
|
|
|
9a9eba |
sftp-server.c | 6 +++---
|
|
|
9a9eba |
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
|
9a9eba |
|
|
|
9a9eba |
diff --git a/sftp-server.c b/sftp-server.c
|
|
|
9a9eba |
index 3619cdfc0..df0fb5068 100644
|
|
|
9a9eba |
--- a/sftp-server.c
|
|
|
9a9eba |
+++ b/sftp-server.c
|
|
|
9a9eba |
@@ -1,4 +1,4 @@
|
|
|
9a9eba |
-/* $OpenBSD: sftp-server.c,v 1.110 2016/09/12 01:22:38 deraadt Exp $ */
|
|
|
9a9eba |
+/* $OpenBSD: sftp-server.c,v 1.111 2017/04/04 00:24:56 djm Exp $ */
|
|
|
9a9eba |
/*
|
|
|
9a9eba |
* Copyright (c) 2000-2004 Markus Friedl. All rights reserved.
|
|
|
9a9eba |
*
|
|
|
9a9eba |
@@ -691,8 +691,8 @@ process_open(u_int32_t id)
|
|
|
9a9eba |
logit("open \"%s\" flags %s mode 0%o",
|
|
|
9a9eba |
name, string_from_portable(pflags), mode);
|
|
|
9a9eba |
if (readonly &&
|
|
|
9a9eba |
- ((flags & O_ACCMODE) == O_WRONLY ||
|
|
|
9a9eba |
- (flags & O_ACCMODE) == O_RDWR)) {
|
|
|
9a9eba |
+ ((flags & O_ACCMODE) != O_RDONLY ||
|
|
|
9a9eba |
+ (flags & (O_CREAT|O_TRUNC)) != 0)) {
|
|
|
9a9eba |
verbose("Refusing open request in read-only mode");
|
|
|
9a9eba |
status = SSH2_FX_PERMISSION_DENIED;
|
|
|
9a9eba |
} else {
|
|
|
9a9eba |
|