# HG changeset patch
# Parent  8a009ace74e43d2117cc4a17600b3de60ab08de4

diff --git a/src/fileio.c b/src/fileio.c
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -509,9 +509,16 @@ readfile(
 	     * (they must not write the swapfile).
 	     * Add the "read" and "write" bits for the user, otherwise we may
 	     * not be able to write to the file ourselves.
+	     * Also respect umask.
 	     * Setting the bits is done below, after creating the swap file.
 	     */
-	    swap_mode = (st.st_mode & 0644) | 0600;
+	    {
+		mode_t	    umask_save;
+
+		umask_save = umask(0);	    /* Get current umask. */
+		(void)umask(umask_save);
+		swap_mode = (st.st_mode & 0644 & ~umask_save) | 0600;
+	    }
 #endif
 #ifdef FEAT_CW_EDITOR
 	    /* Get the FSSpec on MacOS
