kentpeacock / rpms / openssh

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