Skip to content

Commit 9bde950

Browse files
authored
Merge pull request #414 from citrus-it/vim
vim: Fix CVE-2017-17087
2 parents 7d61195 + e70d698 commit 9bde950

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

build/vim/build.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/bash
22
#
3-
# CDDL HEADER START
3+
# {{ CDDL HEADER START
44
#
55
# The contents of this file are subject to the terms of the
66
# Common Development and Distribution License, Version 1.0 only
@@ -18,8 +18,7 @@
1818
# fields enclosed by brackets "[]" replaced with your own identifying
1919
# information: Portions Copyright [yyyy] [name of copyright owner]
2020
#
21-
# CDDL HEADER END
22-
#
21+
# CDDL HEADER END }}}
2322
#
2423
# Copyright 2016 OmniTI Computer Consulting, Inc. All rights reserved.
2524
# Copyright 2017 OmniOS Community Edition (OmniOSce) Association.
@@ -29,6 +28,7 @@
2928
. ../../lib/functions.sh
3029

3130
PROG=vim
31+
# This is the last available bundled version
3232
VER=8.0.586
3333
PKG=editor/vim
3434
SUMMARY="Vi IMproved"
@@ -50,7 +50,6 @@ CONFIGURE_OPTS="
5050
--disable-gui
5151
--disable-gtktest
5252
"
53-
reset_configure_opts
5453

5554
init
5655
download_source $PROG $PROG $VER
@@ -62,4 +61,4 @@ make_package
6261
clean_up
6362

6463
# Vim hints
65-
# vim:ts=4:sw=4:et:
64+
# vim:ts=4:sw=4:et:fdm=marker
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Patch 8.0.1263
2+
Problem: Others can read the swap file if a user is careless with his
3+
primary group.
4+
Solution: If the group permission allows for reading but the world
5+
permissions doesn't, make sure the group is right.
6+
7+
diff -pruN '--exclude=*.orig' vim80~/src/fileio.c vim80/src/fileio.c
8+
--- vim80~/src/fileio.c 2017-04-07 17:40:58.000000000 +0000
9+
+++ vim80/src/fileio.c 2017-12-01 16:31:01.109766011 +0000
10+
@@ -716,7 +716,29 @@ readfile(
11+
/* Set swap file protection bits after creating it. */
12+
if (swap_mode > 0 && curbuf->b_ml.ml_mfp != NULL
13+
&& curbuf->b_ml.ml_mfp->mf_fname != NULL)
14+
- (void)mch_setperm(curbuf->b_ml.ml_mfp->mf_fname, (long)swap_mode);
15+
+ {
16+
+ char_u *swap_fname = curbuf->b_ml.ml_mfp->mf_fname;
17+
+
18+
+ /*
19+
+ * If the group-read bit is set but not the world-read bit, then
20+
+ * the group must be equal to the group of the original file. If
21+
+ * we can't make that happen then reset the group-read bit. This
22+
+ * avoids making the swap file readable to more users when the
23+
+ * primary group of the user is too permissive.
24+
+ */
25+
+ if ((swap_mode & 044) == 040)
26+
+ {
27+
+ stat_T swap_st;
28+
+
29+
+ if (mch_stat((char *)swap_fname, &swap_st) >= 0
30+
+ && st.st_gid != swap_st.st_gid
31+
+ && fchown(curbuf->b_ml.ml_mfp->mf_fd, -1, st.st_gid)
32+
+ == -1)
33+
+ swap_mode &= 0600;
34+
+ }
35+
+
36+
+ (void)mch_setperm(swap_fname, (long)swap_mode);
37+
+ }
38+
#endif
39+
}
40+

build/vim/patches/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.0.1263-CVE-2017-17087

0 commit comments

Comments
 (0)