vi: stale prototype

2014-11-15 Thread Martin Natano
The sscr_pty() function has been removed in r1.18. Let's kill the
remaining prototype.

cheers,
natano


Index: ex/ex_script.c
===
RCS file: /cvs/src/usr.bin/vi/ex/ex_script.c,v
retrieving revision 1.21
diff -u -r1.21 ex_script.c
--- ex/ex_script.c  12 Nov 2014 16:29:04 -  1.21
+++ ex/ex_script.c  15 Nov 2014 09:15:41 -
@@ -44,7 +44,6 @@
 static int sscr_init(SCR *);
 static int sscr_insert(SCR *);
 static int sscr_matchprompt(SCR *, char *, size_t, size_t *);
-static int sscr_pty(int *, int *, char *, size_t, struct termios *, void 
*);
 static int sscr_setprompt(SCR *, char *, size_t);
 
 /*



vi: perl api

2014-11-15 Thread Martin Natano
When building vi with PERLINTERP=yes the build errors out with the
following message:

/usr/src/usr.bin/vi/build/../ex/ex_perl.c: In function 'ex_perl':
/usr/src/usr.bin/vi/build/../ex/ex_perl.c:59: error: implicit declaration of 
function 'perl_ex_perl'
/usr/src/usr.bin/vi/build/../ex/ex_perl.c:60: error: implicit declaration of 
function 'perl_ex_perldo'

This can be easily fixed by adding a missing '#include perl_extern.h'
to ex_perl.c. After adding the missing include, there is another error:

/usr/src/usr.bin/vi/build/../ex/ex_script.c: In function 'sscr_init':
/usr/src/usr.bin/vi/build/../ex/ex_script.c:118: error: implicit declaration of 
function 'openpty'

The system util.h header is shadowed by the eponymous perl header. This
specific errors exists since December 2012. I strongly suspect that no
one uses the perl extension of vi - Let's remove it!

See the diff below.

cheers,
natano


Index: LAYOUT
===
RCS file: /cvs/src/usr.bin/vi/LAYOUT,v
retrieving revision 1.5
diff -u -r1.5 LAYOUT
--- LAYOUT  6 Nov 2014 11:35:02 -   1.5
+++ LAYOUT  15 Nov 2014 07:50:26 -
@@ -91,11 +91,5 @@
 include/
Replacement include files.
 
-perl_api/
-   Source code supporting the Perl scripting language for nvi.
-
-perl_scripts/
-   Scripts for Perl included with nvi.
-
 vi/
The vi source code.
Index: README
===
RCS file: /cvs/src/usr.bin/vi/README,v
retrieving revision 1.11
diff -u -r1.11 README
--- README  6 Nov 2014 11:35:02 -   1.11
+++ README  15 Nov 2014 07:50:40 -
@@ -23,8 +23,6 @@
 docs/USD.doc/vitut  An Introduction to Display Editing with Vi.
 ex  Ex source code.
 include ... Replacement include files.
-perl_api .. Perl scripting language support.
-perl_scripts .. Perl scripts.
 vi  Vi source code.
 
 Bug fixes and updated versions of this software will periodically be made
Index: build/Makefile
===
RCS file: /cvs/src/usr.bin/vi/build/Makefile,v
retrieving revision 1.20
diff -u -r1.20 Makefile
--- build/Makefile  14 Nov 2014 20:26:12 -  1.20
+++ build/Makefile  15 Nov 2014 07:50:05 -
@@ -3,9 +3,6 @@
 
 PROG=  vi
 
-# Uncomment to build with an embedded perl interpreter
-#PERLINTERP=   yes
-
 # Modern curses (ncurses)
 CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../include
 LDADD+=-lcurses
@@ -24,7 +21,7 @@
ex_at.c ex_bang.c ex_cd.c ex_cmd.c ex_cscope.c ex_delete.c \
ex_display.c ex_edit.c ex_equal.c ex_file.c ex_filter.c \
ex_global.c ex_init.c ex_join.c ex_map.c ex_mark.c ex_mkexrc.c \
-   ex_move.c ex_open.c ex_perl.c ex_preserve.c ex_print.c ex_put.c \
+   ex_move.c ex_open.c ex_preserve.c ex_print.c ex_put.c \
ex_quit.c ex_read.c ex_screen.c ex_script.c ex_set.c ex_shell.c \
ex_shift.c ex_source.c ex_stop.c ex_subst.c ex_tag.c \
ex_txt.c ex_undo.c ex_usage.c ex_util.c ex_version.c ex_visual.c \
@@ -38,29 +35,12 @@
v_zexit.c vi.c vs_line.c vs_msg.c vs_refresh.c vs_relative.c \
vs_smap.c vs_split.c
 
-.ifdef PERLINTERP
-SRCS+= api.c perl.c perlsfio.c
-PERLARCH!=perl -MConfig -e 'print $$Config{archlibexp}'
-CFLAGS+=-DHAVE_PERL_5_003_01 -DHAVE_PERL_INTERP -I${PERLARCH}/CORE
-LDADD+= -lperl ${PERLARCH}/auto/DynaLoader/DynaLoader.a
-DPADD+= ${LIBPERL}
-.endif
-
 LINKS= ${BINDIR}/vi ${BINDIR}/ex
 LINKS+=${BINDIR}/vi ${BINDIR}/view
 MLINKS=vi.1 ex.1
 MLINKS+=   vi.1 view.1
 
-CLEANFILES+= VI.pm perl.c
-
-.PATH: ${.CURDIR}/../vi ${.CURDIR}/../ex ${.CURDIR}/../cl ${.CURDIR}/../common 
${.CURDIR}/../perl_api ${.CURDIR}/../docs/USD.doc/vi.man
-
-perl.c: ${.CURDIR}/../perl_api/perl.xs ${.CURDIR}/../perl_api/typemap
-   echo #define _PATH_PERLSCRIPTS \${SHAREDIR}/vi/perl\  ${.TARGET}
-   perl /usr/libdata/perl5/ExtUtils/xsubpp -typemap \
-   /usr/libdata/perl5/ExtUtils/typemap ${.CURDIR}/../perl_api/perl.xs 
 ${.TARGET}
-   (perl  -ne 'print sub $$1 {\$$curscr-$$1(\@_)}\n \
-   if /newXS\(VI::([^:]*)/;' ${.TARGET} ; echo 1;)  VI.pm
+.PATH: ${.CURDIR}/../vi ${.CURDIR}/../ex ${.CURDIR}/../cl ${.CURDIR}/../common 
${.CURDIR}/../docs/USD.doc/vi.man
 
 .include ../../Makefile.inc
 .include bsd.prog.mk
@@ -71,7 +51,3 @@
${INSTALL} -d ${DESTDIR}${SHAREDIR}/vi/catalog
(cd ${.CURDIR}/../catalog  ${INSTALL} -m ${NONBINMODE} -c ${CATALOGS} 
${DESTDIR}/usr/share/vi/catalog )
${INSTALL} -m ${BINMODE} -o ${BINOWN} -g ${BINGRP} -c 
${.CURDIR}/recover ${DESTDIR}/usr/libexec/vi.recover
-.ifdef PERLINTERP
-   ${INSTALL} -d ${DESTDIR}${SHAREDIR}/vi/perl
-   (cd ${.CURDIR}/../perl_scripts; for i in *.pl; do ${INSTALL} -m 
${NONBINMODE} -c $$i ${DESTDIR}/usr/share/vi/perl; done)
-.endif
Index: common/api.c

use siphash to protect the mroute hash

2014-11-15 Thread David Gwynne
i have no idea how to test this.

tests? oks?

Index: ip_mroute.c
===
RCS file: /cvs/src/sys/netinet/ip_mroute.c,v
retrieving revision 1.71
diff -u -p -r1.71 ip_mroute.c
--- ip_mroute.c 30 Sep 2014 12:54:22 -  1.71
+++ ip_mroute.c 15 Nov 2014 11:18:29 -
@@ -93,6 +93,9 @@
 
 #include sys/stdarg.h
 
+#include dev/rndvar.h
+#include crypto/siphash.h
+
 #define IP_MULTICASTOPTS 0
 #defineM_PULLUP(m, len)
 \
do { \
@@ -110,11 +113,12 @@ int   ip_mrtproto = IGMP_DVMRP;/* for
 #define NO_RTE_FOUND   0x1
 #define RTE_FOUND  0x2
 
-#defineMFCHASH(a, g)   
\
-   a).s_addr  20) ^ ((a).s_addr  10) ^ (a).s_addr ^\
-   ((g).s_addr  20) ^ ((g).s_addr  10) ^ (g).s_addr)  mfchash)
+u_int32_t _mfchash(struct in_addr, struct in_addr);
+
+#defineMFCHASH(a, g) _mfchash((a), (g))
 LIST_HEAD(mfchashhdr, mfc) *mfchashtbl;
 u_long mfchash;
+SIPHASH_KEY mfchashkey;
 
 u_char nexpire[MFCTBLSIZ];
 struct vif viftable[MAXVIFS];
@@ -281,8 +285,10 @@ static struct mfc *
 mfc_find(struct in_addr *o, struct in_addr *g)
 {
struct mfc *rt;
+   u_int32_t hash;
 
-   LIST_FOREACH(rt, mfchashtbl[MFCHASH(*o, *g)], mfc_hash) {
+   hash = MFCHASH(*o, *g);
+   LIST_FOREACH(rt, mfchashtbl[hash], mfc_hash) {
if (in_hosteq(rt-mfc_origin, *o) 
in_hosteq(rt-mfc_mcastgrp, *g) 
(rt-mfc_stall == NULL))
@@ -498,6 +504,7 @@ ip_mrouter_init(struct socket *so, struc
ip_mrouter = so;
 
mfchashtbl = hashinit(MFCTBLSIZ, M_MRTABLE, M_WAITOK, mfchash);
+   arc4random_buf(mfchashkey, sizeof(mfchashkey));
memset(nexpire, 0, sizeof(nexpire));
 
pim_assert = 0;
@@ -509,6 +516,18 @@ ip_mrouter_init(struct socket *so, struc
log(LOG_DEBUG, ip_mrouter_init\n);
 
return (0);
+}
+
+u_int32_t
+_mfchash(struct in_addr o, struct in_addr g)
+{
+   SIPHASH_CTX ctx;
+
+   SipHash24_Init(ctx, mfchashkey);
+   SipHash24_Update(ctx, o.s_addr, sizeof(o.s_addr));
+   SipHash24_Update(ctx, g.s_addr, sizeof(g.s_addr));
+
+   return (SipHash24_End(ctx)  mfchash);
 }
 
 /*



vi: the LIBRARY is a lie

2014-11-15 Thread Martin Natano
The LIBRARY define is undocumenteed and triggers the same conditional
inclusions as PURIFY does.

See the diff below, no binary change.

cheers,
natano


Index: cl/cl_main.c
===
RCS file: /cvs/src/usr.bin/vi/cl/cl_main.c,v
retrieving revision 1.24
diff -u -r1.24 cl_main.c
--- cl/cl_main.c14 Nov 2014 20:27:03 -  1.24
+++ cl/cl_main.c15 Nov 2014 10:34:11 -
@@ -128,7 +128,7 @@
}
 
/* Free the global and CL private areas. */
-#if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY)
+#if defined(DEBUG) || defined(PURIFY)
free(clp);
free(gp);
 #endif
Index: common/main.c
===
RCS file: /cvs/src/usr.bin/vi/common/main.c,v
retrieving revision 1.24
diff -u -r1.24 main.c
--- common/main.c   14 Nov 2014 20:27:03 -  1.24
+++ common/main.c   15 Nov 2014 10:34:23 -
@@ -461,7 +461,7 @@
perl_end(gp);
 #endif
 
-#if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY)
+#if defined(DEBUG) || defined(PURIFY)
{ FREF *frp;
/* Free FREF's. */
while ((frp = TAILQ_FIRST(gp-frefq))) {
@@ -505,13 +505,13 @@
(void)fprintf(stderr, %s%.*s,
mp-mtype == M_ERR ? ex/vi:  : , (int)mp-len, mp-buf);
LIST_REMOVE(mp, q);
-#if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY)
+#if defined(DEBUG) || defined(PURIFY)
free(mp-buf);
free(mp);
 #endif
}
 
-#if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY)
+#if defined(DEBUG) || defined(PURIFY)
/* Free any temporary space. */
if (gp-tmp_bp != NULL)
free(gp-tmp_bp);
Index: perl_api/perl.xs
===
RCS file: /cvs/src/usr.bin/vi/perl_api/perl.xs,v
retrieving revision 1.4
diff -u -r1.4 perl.xs
--- perl_api/perl.xs27 Oct 2009 23:59:47 -  1.4
+++ perl_api/perl.xs15 Nov 2014 10:34:53 -
@@ -74,7 +74,7 @@
/*Irestartop = 0;   / * XXX */
perl_run(gp-perl_interp);
perl_destruct(gp-perl_interp);
-#if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY)
+#if defined(DEBUG) || defined(PURIFY)
perl_free(gp-perl_interp);
 #endif
}



Re: VPLS patch [0/3]: introduction

2014-11-15 Thread David Gwynne

 On 15 Nov 2014, at 3:40 am, Stuart Henderson st...@openbsd.org wrote:
 
 On 2014/11/14 15:24, Rafael Zalamena wrote:
 On Fri, Nov 14, 2014 at 05:41:32PM +0100, Mike Belopuhov wrote:
 
 is it possible to call it something other than just wire(4)?
 vpls maybe?
 
 pseudowire(4) then? (looks long to me)
 I wouldn't call vpls as it may be expanded later to do also VPWS.
 
 pwe(4)?
 
 though, wire(4) doesn't seem bad to me..

merge it into gif(4).

how about mpw(4) for MPLS Pseudo Wire like mpe(4) is MPLS Provider Edge?

or merge it into gif(4) ;)



locate - change sizeof(char **) to sizeof(char *)

2014-11-15 Thread Nicolas Bedos
In usr.bin/locate/locate/locate.c and util.c the variable dbv is defined
as a pointer to char * and is used to access the path to every database
provided to locate. E.g. when running

locate -d /path/to/db1 -d /path/to/db2 -d /path/to/db3 *

*dbv points to '/path/to/db1'
*(dbv+1) points to '/path/to/db2'
*(dbv+2) points to '/path/to/db3'

However dbv is initialized with the following call

dbv = malloc(sizeof(char **))

which I believe should be 

dbv = malloc(sizeof(char *))

The same goes for the variable newdbv. Please find the corresponding
diff below. No binary change on amd64 since sizeof(char **) ==
sizeof(char *). 

Nicolas Bedos



Index: usr.bin/locate/locate/util.c
===
RCS file: /cvs/src/usr.bin/locate/locate/util.c,v
retrieving revision 1.11
diff -u -p -u -r1.11 util.c
--- usr.bin/locate/locate/util.c8 Oct 2014 04:04:37 -   1.11
+++ usr.bin/locate/locate/util.c15 Nov 2014 14:08:15 -
@@ -89,7 +89,7 @@ colon(dbv, path, dot)
char **pv;
 
if (dbv == NULL) {
-   if ((dbv = malloc(sizeof(char **))) == NULL)
+   if ((dbv = malloc(sizeof(char *))) == NULL)
err(1, malloc);
*dbv = NULL;
}
@@ -123,7 +123,7 @@ colon(dbv, path, dot)
}
/* increase dbv with element p */
if ((newdbv = reallocarray(dbv, vlen + 2,
-   sizeof(char **))) == NULL)
+   sizeof(char *))) == NULL)
err(1, realloc);
dbv = newdbv;
*(dbv + vlen) = p;



vi: mvchgat

2014-11-15 Thread Martin Natano
I missed this part of the workaround for a missing mvchgat(); no binary
change.

Index: cl/cl_funcs.c
===
RCS file: /cvs/src/usr.bin/vi/cl/cl_funcs.c,v
retrieving revision 1.17
diff -u -r1.17 cl_funcs.c
--- cl/cl_funcs.c   12 Nov 2014 16:29:04 -  1.17
+++ cl/cl_funcs.c   15 Nov 2014 19:58:25 -
@@ -261,10 +261,6 @@
 int
 cl_deleteln(SCR *sp)
 {
-#ifndef mvchgat
-   CHAR_T ch;
-   size_t col, lno, spcnt;
-#endif
size_t oldy, oldx;
 
/*


cheers,
natano



Re: locate - change sizeof(char **) to sizeof(char *)

2014-11-15 Thread Ted Unangst
On Sat, Nov 15, 2014 at 18:42, Nicolas Bedos wrote:
 In usr.bin/locate/locate/locate.c and util.c the variable dbv is defined
 as a pointer to char * and is used to access the path to every database
 provided to locate. E.g. when running
 
 locate -d /path/to/db1 -d /path/to/db2 -d /path/to/db3 *
 
 *dbv points to '/path/to/db1'
 *(dbv+1) points to '/path/to/db2'
 *(dbv+2) points to '/path/to/db3'
 
 However dbv is initialized with the following call
 
 dbv = malloc(sizeof(char **))
 
 which I believe should be
 
 dbv = malloc(sizeof(char *))
 
 The same goes for the variable newdbv. Please find the corresponding
 diff below. No binary change on amd64 since sizeof(char **) ==
 sizeof(char *).

I think using sizeof(*dbv) would be the better idiom.



vi: filemodes

2014-11-15 Thread Martin Natano
The S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH mode can be
replaced by DEFFILEMODE.

See the diff below; no binary change.

cheers,
natano


Index: common/exf.c
===
RCS file: /cvs/src/usr.bin/vi/common/exf.c,v
retrieving revision 1.32
diff -u -r1.32 exf.c
--- common/exf.c14 Nov 2014 20:23:56 -  1.32
+++ common/exf.c15 Nov 2014 18:52:41 -
@@ -255,9 +255,7 @@
 
/* Open a db structure. */
if ((ep-db = dbopen(rcv_name == NULL ? oname : NULL,
-   O_NONBLOCK | O_RDONLY,
-   S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH,
-   DB_RECNO, oinfo)) == NULL) {
+   O_NONBLOCK | O_RDONLY, DEFFILEMODE, DB_RECNO, oinfo)) == NULL) {
msgq_str(sp,
M_SYSERR, rcv_name == NULL ? oname : rcv_name, %s);
/*
@@ -824,8 +822,7 @@
 
/* Open the file. */
SIGBLOCK;
-   if ((fd = open(name, oflags,
-   S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH))  0) {
+   if ((fd = open(name, oflags, DEFFILEMODE))  0) {
msgq_str(sp, M_SYSERR, name, %s);
SIGUNBLOCK;
return (1);



Re: locate - change sizeof(char **) to sizeof(char *)

2014-11-15 Thread Nicolas Bedos
Ted Unangst wrote:
 I think using sizeof(*dbv) would be the better idiom.

Here's an updated diff, including Tobias Stoeckmann's fix.


Index: src/usr.bin/locate/locate/util.c
===
RCS file: /cvs/src/usr.bin/locate/locate/util.c,v
retrieving revision 1.11
diff -u -p -u -r1.11 util.c
--- src/usr.bin/locate/locate/util.c8 Oct 2014 04:04:37 -   1.11
+++ src/usr.bin/locate/locate/util.c15 Nov 2014 20:51:09 -
@@ -72,8 +72,8 @@ check_bigram_char(ch)
 
 /* split a colon separated string into a char vector
  *
- * bla:foo - {foo, bla}
- * bla:- {foo, dot}
+ * bla:foo - {bla, foo}
+ * bla:- {bla, dot}
  * bla - {bla}
  *- do nothing
  *
@@ -89,7 +89,7 @@ colon(dbv, path, dot)
char **pv;
 
if (dbv == NULL) {
-   if ((dbv = malloc(sizeof(char **))) == NULL)
+   if ((dbv = malloc(sizeof(*dbv))) == NULL)
err(1, malloc);
*dbv = NULL;
}
@@ -123,7 +123,7 @@ colon(dbv, path, dot)
}
/* increase dbv with element p */
if ((newdbv = reallocarray(dbv, vlen + 2,
-   sizeof(char **))) == NULL)
+   sizeof(*newdbv))) == NULL)
err(1, realloc);
dbv = newdbv;
*(dbv + vlen) = p;



mg(1): Second set of patches

2014-11-15 Thread Kamil Rytarowski
Hello,

I'm attaching two enhancements against mg(1):

0001-Include-limits.h-for-INT_MIN-and-INT_MAX.patch
0002-Comparison-of-array-bp-b_fname-not-equal-to-a-null-p.patch

Regards,From f4a353e59af01b14455a6302e6309887b70796ba Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski n...@gmx.com
Date: Sat, 15 Nov 2014 09:03:19 +
Subject: [PATCH 1/2] Include limits.h for INT_MIN and INT_MAX

---
 basic.c | 1 +
 cscope.c| 1 +
 extend.c| 1 +
 grep.c  | 1 +
 line.c  | 1 +
 main.c  | 1 +
 paragraph.c | 1 +
 7 files changed, 7 insertions(+)

diff --git a/basic.c b/basic.c
index 5d6f093..340bd8d 100644
--- a/basic.c
+++ b/basic.c
@@ -14,6 +14,7 @@
 #include def.h
 
 #include ctype.h
+#include limits.h
 
 /*
  * Go to beginning of line.
diff --git a/cscope.c b/cscope.c
index b334e6b..9f79579 100644
--- a/cscope.c
+++ b/cscope.c
@@ -13,6 +13,7 @@
 #include ctype.h
 #include fcntl.h
 #include fnmatch.h
+#include limits.h
 #include stdio.h
 #include stdlib.h
 #include string.h
diff --git a/extend.c b/extend.c
index 6196691..2f3d965 100644
--- a/extend.c
+++ b/extend.c
@@ -12,6 +12,7 @@
 
 #include sys/types.h
 #include ctype.h
+#include limits.h
 
 #include macro.h
 
diff --git a/grep.c b/grep.c
index 55f7ae1..055bf33 100644
--- a/grep.c
+++ b/grep.c
@@ -9,6 +9,7 @@
 #include sys/types.h
 #include ctype.h
 #include libgen.h
+#include limits.h
 #include time.h
 
 int	 globalwd = FALSE;
diff --git a/line.c b/line.c
index 51d1765..ca0b776 100644
--- a/line.c
+++ b/line.c
@@ -19,6 +19,7 @@
 
 #include def.h
 
+#include limits.h
 #include stdlib.h
 #include string.h
 
diff --git a/main.c b/main.c
index 9204d63..7bcfe61 100644
--- a/main.c
+++ b/main.c
@@ -12,6 +12,7 @@
 #include macro.h
 
 #include err.h
+#include limits.h
 #include locale.h
 
 int		 thisflag;			/* flags, this command	*/
diff --git a/paragraph.c b/paragraph.c
index d45efc4..9d593f7 100644
--- a/paragraph.c
+++ b/paragraph.c
@@ -8,6 +8,7 @@
  */
 
 #include ctype.h
+#include limits.h
 
 #include def.h
 
-- 
2.1.0

From 4e3150317ef5e73933b0c53b3163861710085f67 Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski n...@gmx.com
Date: Sat, 15 Nov 2014 16:29:07 +
Subject: [PATCH 2/2] Comparison of array 'bp-b_fname' not equal to a null
 pointer is always true

---
 buffer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/buffer.c b/buffer.c
index 331fbbb..51b2838 100644
--- a/buffer.c
+++ b/buffer.c
@@ -458,8 +458,7 @@ anycb(int f)
 	char		 pbuf[NFILEN + 11];
 
 	for (bp = bheadp; bp != NULL; bp = bp-b_bufp) {
-		if (bp-b_fname != NULL  *(bp-b_fname) != '\0' 
-		(bp-b_flag  BFCHG) != 0) {
+		if (*(bp-b_fname) != '\0'  (bp-b_flag  BFCHG) != 0) {
 			ret = snprintf(pbuf, sizeof(pbuf), Save file %s,
 			bp-b_fname);
 			if (ret  0 || ret = sizeof(pbuf)) {
-- 
2.1.0



vi: cl_putchar

2014-11-15 Thread Martin Natano
The cl_putchar() function does nothing, but call putchar(). stacklevel--

cheers,
natano


Index: cl/cl_funcs.c
===
RCS file: /cvs/src/usr.bin/vi/cl/cl_funcs.c,v
retrieving revision 1.17
diff -u -r1.17 cl_funcs.c
--- cl/cl_funcs.c   12 Nov 2014 16:29:04 -  1.17
+++ cl/cl_funcs.c   15 Nov 2014 20:41:22 -
@@ -112,7 +112,7 @@
if (clp-smcup == NULL)
(void)cl_getcap(sp, smcup, clp-smcup);
if (clp-smcup != NULL)
-   (void)tputs(clp-smcup, 1, cl_putchar);
+   (void)tputs(clp-smcup, 1, putchar);
}
} else
if (clp-ti_te != TE_SENT) {
@@ -120,7 +120,7 @@
if (clp-rmcup == NULL)
(void)cl_getcap(sp, rmcup, clp-rmcup);
if (clp-rmcup != NULL)
-   (void)tputs(clp-rmcup, 1, cl_putchar);
+   (void)tputs(clp-rmcup, 1, putchar);
(void)fflush(stdout);
}
(void)fflush(stdout);
@@ -130,9 +130,9 @@
if (clp-smso == NULL)
return (1);
if (on)
-   (void)tputs(clp-smso, 1, cl_putchar);
+   (void)tputs(clp-smso, 1, putchar);
else
-   (void)tputs(clp-rmso, 1, cl_putchar);
+   (void)tputs(clp-rmso, 1, putchar);
(void)fflush(stdout);
} else {
if (on)
@@ -316,10 +316,10 @@
case EX_TERM_SCROLL:
/* Move the cursor up one line if that's possible. */
if (clp-cuu1 != NULL)
-   (void)tputs(clp-cuu1, 1, cl_putchar);
+   (void)tputs(clp-cuu1, 1, putchar);
else if (clp-cup != NULL)
(void)tputs(tgoto(clp-cup,
-   0, LINES - 2), 1, cl_putchar);
+   0, LINES - 2), 1, putchar);
else
return (0);
/* FALLTHROUGH */
@@ -327,7 +327,7 @@
/* Clear the line. */
if (clp-el != NULL) {
(void)putchar('\r');
-   (void)tputs(clp-el, 1, cl_putchar);
+   (void)tputs(clp-el, 1, putchar);
} else {
/*
 * Historically, ex didn't erase the line, so, if the
Index: cl/cl_screen.c
===
RCS file: /cvs/src/usr.bin/vi/cl/cl_screen.c,v
retrieving revision 1.22
diff -u -r1.22 cl_screen.c
--- cl/cl_screen.c  12 Nov 2014 16:29:04 -  1.22
+++ cl/cl_screen.c  15 Nov 2014 20:41:37 -
@@ -107,7 +107,7 @@
 */
if (F_ISSET(sp, SC_EX)  clp-cup != NULL)
tputs(tgoto(clp-cup,
-   0, O_VAL(sp, O_LINES) - 1), 1, cl_putchar);
+   0, O_VAL(sp, O_LINES) - 1), 1, putchar);
} else {
if (cl_vi_init(sp))
return (1);
Index: cl/cl_term.c
===
RCS file: /cvs/src/usr.bin/vi/cl/cl_term.c,v
retrieving revision 1.19
diff -u -r1.19 cl_term.c
--- cl/cl_term.c12 Nov 2014 16:29:04 -  1.19
+++ cl/cl_term.c15 Nov 2014 20:45:21 -
@@ -423,15 +423,3 @@
*colp = col;
return (0);
 }
-
-/*
- * cl_putchar --
- * Function version of putchar, for tputs.
- *
- * PUBLIC: int cl_putchar(int);
- */
-int
-cl_putchar(int ch)
-{
-   return (putchar(ch));
-}
Index: include/cl_extern.h
===
RCS file: /cvs/src/usr.bin/vi/include/cl_extern.h,v
retrieving revision 1.7
diff -u -r1.7 cl_extern.h
--- include/cl_extern.h 6 Nov 2014 10:48:52 -   1.7
+++ include/cl_extern.h 15 Nov 2014 20:44:06 -
@@ -26,4 +26,3 @@
 int cl_optchange(SCR *, int, char *, u_long *);
 int cl_omesg(SCR *, CL_PRIVATE *, int);
 int cl_ssize(SCR *, int, size_t *, size_t *, int *);
-int cl_putchar(int);



vi: #include workarounds

2014-11-15 Thread Martin Natano
Remove #include workarounds; no binary change.

cheers,
natano


Index: common/exf.c
===
RCS file: /cvs/src/usr.bin/vi/common/exf.c,v
retrieving revision 1.32
diff -u -r1.32 exf.c
--- common/exf.c14 Nov 2014 20:23:56 -  1.32
+++ common/exf.c15 Nov 2014 20:58:04 -
@@ -15,13 +15,6 @@
 #include sys/queue.h
 #include sys/stat.h
 
-/*
- * We include sys/file.h, because the flock(2) and open(2) #defines
- * were found there on historical systems.  We also include fcntl.h
- * because the open(2) #defines are found there on newer systems.
- */
-#include sys/file.h
-
 #include bitstring.h
 #include dirent.h
 #include errno.h
Index: ex/ex_script.c
===
RCS file: /cvs/src/usr.bin/vi/ex/ex_script.c,v
retrieving revision 1.21
diff -u -r1.21 ex_script.c
--- ex/ex_script.c  12 Nov 2014 16:29:04 -  1.21
+++ ex/ex_script.c  15 Nov 2014 21:12:52 -
@@ -24,10 +24,10 @@
 #include bitstring.h
 #include errno.h
 #include fcntl.h
-#include stdio.h /* XXX: OSF/1 bug: include before grp.h */
 #include grp.h
 #include limits.h
 #include poll.h
+#include stdio.h
 #include stdlib.h
 #include string.h
 #include termios.h



Re: Missing include in sys/ipc.h

2014-11-15 Thread Philip Guenther
On Thu, Nov 13, 2014 at 10:31 PM, Brad Smith b...@comstyle.com wrote:
 ping. Discussion died out. Can we please move this issue forward?

It's in


Philip



mount_tmpfs(8) MINOR man page correction

2014-11-15 Thread bytevolcano
The manual page for mount_tmpfs(8) states that it was included in
OpenBSD 5.4, when the first -release with tmpfs was 5.5.

Corrected in the following diff:



Index: sbin/mount_tmpfs/mount_tmpfs.8
===
RCS file: /cvs/src/sbin/mount_tmpfs/mount_tmpfs.8,v
retrieving revision 1.3
diff -u -p -r1.3 mount_tmpfs.8
--- sbin/mount_tmpfs/mount_tmpfs.8  5 Feb 2014 15:32:26
-   1.3 +++ sbin/mount_tmpfs/mount_tmpfs.8  16 Nov 2014
01:44:22 - @@ -133,7 +133,7 @@ The
 utility first appeared in
 .Nx 4.0
 and
-.Ox 5.4 .
+.Ox 5.5 .
 .Sh CAVEATS
 The update of mount options (through mount -u) is currently not
supported. .Sh BUGS



Re: [PATCH] mfs improvements

2014-11-15 Thread Theo de Raadt
Nope.  That is unsuitable use of issetugid.  This is not a setuid program.

 2. Call and check issetugid() to ensure the information from getenv()
 is safe to use. If not, default to _PATH_TMP.


Index: sbin/newfs/newfs.c
===
RCS file: /cvs/src/sbin/newfs/newfs.c,v
retrieving revision 1.97
diff -u -p -r1.97 newfs.c
--- sbin/newfs/newfs.c 20 Jul 2014 01:38:40 -  1.97
+++ sbin/newfs/newfs.c 16 Nov 2014 01:17:01 -
@@ -794,7 +797,8 @@ gettmpmnt(char *mountpoint, size_t len)
   struct statfs fs;
   size_t n;
 
-  tmp = getenv(TMPDIR);
+  if(issetugid() == 0)
+  tmp = getenv(TMPDIR);
   if (tmp == NULL || *tmp == '\0')
   tmp = _PATH_TMP;
 





Re: mg(1) compatibility patches

2014-11-15 Thread Kamil Rytarowski
 Sent: Sunday, November 16, 2014 at 1:09 AM
 From: Philip Guenther guent...@gmail.com
 To: Kamil Rytarowski n...@gmx.com
 Cc: Theo de Raadt dera...@cvs.openbsd.org, tech-openbsd 
 tech@openbsd.org, Ted Unangst t...@tedunangst.com
 Subject: Re: mg(1) compatibility patches

 On Fri, Nov 14, 2014 at 3:16 PM, Kamil Rytarowski n...@gmx.com wrote:
 ...
  Feel free to evaluate the rest of the patches (0002-0005),
  as they are meant to be generic.
 
 With a couple, I've committed those.  Thanks!
 
 
 Philip Guenther
 
 

Thank you!



Re: mg(1): Second set of patches

2014-11-15 Thread Theo de Raadt
Good idea. Please go for it, this MAX() was problematic at SunOS.

SunOS portabibility is not relevant today.