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