CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: gutteridge Date: Mon Feb 13 23:08:43 UTC 2023 Modified Files: src/external/bsd/nvi/dist/common: search.c Log Message: search.c: correctly handle escaped backslashes Addresses PR bin/57106 from Bosco G. G., who supplied the patch. (This was also committed in the nvi2 sources: https://github.com/lichray/nvi2/commit/e7054267a371d5caa81edb218f5c8388e11b5197) To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/search.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: gutteridge Date: Mon Feb 13 23:08:43 UTC 2023 Modified Files: src/external/bsd/nvi/dist/common: search.c Log Message: search.c: correctly handle escaped backslashes Addresses PR bin/57106 from Bosco G. G., who supplied the patch. (This was also committed in the nvi2 sources: https://github.com/lichray/nvi2/commit/e7054267a371d5caa81edb218f5c8388e11b5197) To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/search.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/search.c diff -u src/external/bsd/nvi/dist/common/search.c:1.4 src/external/bsd/nvi/dist/common/search.c:1.5 --- src/external/bsd/nvi/dist/common/search.c:1.4 Wed Nov 22 16:17:30 2017 +++ src/external/bsd/nvi/dist/common/search.c Mon Feb 13 23:08:43 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: search.c,v 1.4 2017/11/22 16:17:30 rin Exp $ */ +/* $NetBSD: search.c,v 1.5 2023/02/13 23:08:43 gutteridge Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: search.c,v 10.31 2001/06/25 15:19:12 skimo Exp (Berkeley) Date: 2001/06/25 15:19:12 "; #endif /* not lint */ #else -__RCSID("$NetBSD: search.c,v 1.4 2017/11/22 16:17:30 rin Exp $"); +__RCSID("$NetBSD: search.c,v 1.5 2023/02/13 23:08:43 gutteridge Exp $"); #endif #include @@ -110,9 +110,14 @@ prev: if (sp->re == NULL) { ++p; break; } - if (plen > 1 && p[0] == '\\' && p[1] == delim) { -++p; ---plen; + if (plen > 1 && p[0] == '\\') { +if(p[1] == delim) { + ++p; + --plen; +} else if(p[1] == '\\') { + *t++ = *p++; + --plen; +} } } if (epp != NULL)
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Tue Aug 7 11:25:45 UTC 2018 Modified Files: src/external/bsd/nvi/dist/common: vi_db1.c Log Message: Remove unnecessary buffer allocation and memcpy. Partially taken from nvi2. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/bsd/nvi/dist/common/vi_db1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/vi_db1.c diff -u src/external/bsd/nvi/dist/common/vi_db1.c:1.9 src/external/bsd/nvi/dist/common/vi_db1.c:1.10 --- src/external/bsd/nvi/dist/common/vi_db1.c:1.9 Fri Nov 10 14:35:25 2017 +++ src/external/bsd/nvi/dist/common/vi_db1.c Tue Aug 7 11:25:45 2018 @@ -15,7 +15,7 @@ static const char sccsid[] = "Id: db1.c,v 10.1 2002/03/09 12:53:57 skimo Exp (Berkeley) Date: 2002/03/09 12:53:57 "; #endif /* not lint */ #else -__RCSID("$NetBSD: vi_db1.c,v 1.9 2017/11/10 14:35:25 rin Exp $"); +__RCSID("$NetBSD: vi_db1.c,v 1.10 2018/08/07 11:25:45 rin Exp $"); #endif #include @@ -98,7 +98,6 @@ db_get(SCR *sp, db_recno_t lno, u_int32_ db_recno_t l1, l2; const CHAR_T *wp; size_t wlen; - size_t nlen; /* * The underlying recno stuff handles zero by returning NULL, but @@ -159,11 +158,6 @@ db_get(SCR *sp, db_recno_t lno, u_int32_ sp->c_lno = OOBLNO; nocache: - nlen = 1024; -retry: - /* data.size contains length in bytes */ - BINC_GOTO(sp, CHAR_T, sp->c_lp, sp->c_blen, nlen); - /* Get the line from the underlying database. */ key.data = key.size = sizeof(lno); @@ -179,12 +173,8 @@ err3: if (lenp != NULL) if (pp != NULL) *pp = NULL; return (1); - case 0: - if (data.size > nlen) { - nlen = data.size; - goto retry; - } else - memcpy(sp->c_lp, data.data, data.size); + default: + break; } if (FILE2INT(sp, data.data, data.size, wp, wlen)) { @@ -199,7 +189,8 @@ err3: if (lenp != NULL) if (wp != data.data) { BINC_GOTOW(sp, sp->c_lp, sp->c_blen, wlen); MEMCPYW(sp->c_lp, wp, wlen); - } + } else + sp->c_lp = data.data; sp->c_lno = lno; sp->c_len = wlen; @@ -560,8 +551,8 @@ alloc_err: msgq(sp, M_DBERR, "007|unable to get last line"); *lnop = 0; return (1); -case 0: - ; + default: + break; } memcpy(, key.data, sizeof(lno)); @@ -570,8 +561,11 @@ alloc_err: FILE2INT(sp, data.data, data.size, wp, wlen); /* Fill the cache. */ - BINC_GOTOW(sp, sp->c_lp, sp->c_blen, wlen); - MEMCPYW(sp->c_lp, wp, wlen); + if (wp != data.data) { + BINC_GOTOW(sp, sp->c_lp, sp->c_blen, wlen); + MEMCPYW(sp->c_lp, wp, wlen); + } else + sp->c_lp = data.data; sp->c_lno = lno; sp->c_len = wlen; }
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Tue Aug 7 11:25:45 UTC 2018 Modified Files: src/external/bsd/nvi/dist/common: vi_db1.c Log Message: Remove unnecessary buffer allocation and memcpy. Partially taken from nvi2. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/bsd/nvi/dist/common/vi_db1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Wed Aug 1 02:48:47 UTC 2018 Modified Files: src/external/bsd/nvi/dist/common: conv.h Log Message: As described in comments, we treat non-spacing chars as single-width ones. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/conv.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/conv.h diff -u src/external/bsd/nvi/dist/common/conv.h:1.3 src/external/bsd/nvi/dist/common/conv.h:1.4 --- src/external/bsd/nvi/dist/common/conv.h:1.3 Sun Jun 3 08:08:36 2018 +++ src/external/bsd/nvi/dist/common/conv.h Wed Aug 1 02:48:47 2018 @@ -1,11 +1,11 @@ -/* $NetBSD: conv.h,v 1.3 2018/06/03 08:08:36 rin Exp $ */ +/* $NetBSD: conv.h,v 1.4 2018/08/01 02:48:47 rin Exp $ */ /* * We ensure that every wide char occupies at least one display width. * See vs_line.c for more details. */ #define WIDE_COL(sp, ch) \ - (CHAR_WIDTH(sp, ch) >= 0 ? CHAR_WIDTH(sp, ch) : 1) + (CHAR_WIDTH(sp, ch) > 0 ? CHAR_WIDTH(sp, ch) : 1) #define KEY_COL(sp, ch) \ (INTISWIDE(ch) ? (size_t)WIDE_COL(sp, ch) : KEY_LEN(sp, ch))
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Wed Aug 1 02:48:47 UTC 2018 Modified Files: src/external/bsd/nvi/dist/common: conv.h Log Message: As described in comments, we treat non-spacing chars as single-width ones. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/conv.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: kamil Date: Mon Jun 25 18:36:36 UTC 2018 Modified Files: src/external/bsd/nvi/dist/common: log1.c Log Message: Include for offsetof(3) To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/nvi/dist/common/log1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/log1.c diff -u src/external/bsd/nvi/dist/common/log1.c:1.5 src/external/bsd/nvi/dist/common/log1.c:1.6 --- src/external/bsd/nvi/dist/common/log1.c:1.5 Mon Jun 25 17:42:34 2018 +++ src/external/bsd/nvi/dist/common/log1.c Mon Jun 25 18:36:36 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: log1.c,v 1.5 2018/06/25 17:42:34 kamil Exp $ */ +/* $NetBSD: log1.c,v 1.6 2018/06/25 18:36:36 kamil Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: log.c,v 10.26 2002/03/02 23:12:13 skimo Exp (Berkeley) Date: 2002/03/02 23:12:13 "; #endif /* not lint */ #else -__RCSID("$NetBSD: log1.c,v 1.5 2018/06/25 17:42:34 kamil Exp $"); +__RCSID("$NetBSD: log1.c,v 1.6 2018/06/25 18:36:36 kamil Exp $"); #endif #include @@ -30,6 +30,7 @@ __RCSID("$NetBSD: log1.c,v 1.5 2018/06/2 #include #include #include +#include #include "common.h"
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: kamil Date: Mon Jun 25 18:36:36 UTC 2018 Modified Files: src/external/bsd/nvi/dist/common: log1.c Log Message: Include for offsetof(3) To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/nvi/dist/common/log1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: kamil Date: Mon Jun 25 17:42:34 UTC 2018 Modified Files: src/external/bsd/nvi/dist/common: log1.c Log Message: Avoid unportable offsetof(3) calculation in nvi in log1.c Detected with MKSANITIZER/UBSan. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/log1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: kamil Date: Mon Jun 25 17:42:34 UTC 2018 Modified Files: src/external/bsd/nvi/dist/common: log1.c Log Message: Avoid unportable offsetof(3) calculation in nvi in log1.c Detected with MKSANITIZER/UBSan. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/log1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/log1.c diff -u src/external/bsd/nvi/dist/common/log1.c:1.4 src/external/bsd/nvi/dist/common/log1.c:1.5 --- src/external/bsd/nvi/dist/common/log1.c:1.4 Sun Jan 26 21:43:45 2014 +++ src/external/bsd/nvi/dist/common/log1.c Mon Jun 25 17:42:34 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: log1.c,v 1.4 2014/01/26 21:43:45 christos Exp $ */ +/* $NetBSD: log1.c,v 1.5 2018/06/25 17:42:34 kamil Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: log.c,v 10.26 2002/03/02 23:12:13 skimo Exp (Berkeley) Date: 2002/03/02 23:12:13 "; #endif /* not lint */ #else -__RCSID("$NetBSD: log1.c,v 1.4 2014/01/26 21:43:45 christos Exp $"); +__RCSID("$NetBSD: log1.c,v 1.5 2018/06/25 17:42:34 kamil Exp $"); #endif #include @@ -88,7 +88,7 @@ typedef struct { chardata[sizeof(u_char) /* type */ + sizeof(db_recno_t)]; CHAR_T str[1]; } log_t; -#define CHAR_T_OFFSET ((char *)(((log_t*)0)->str) - (char *)0) +#define CHAR_T_OFFSET (offsetof(log_t, str)) /* * log_init --
Re: CVS commit: src/external/bsd/nvi/dist/common
On 16.06.2018 22:39, Christos Zoulas wrote: > In article <20180616185452.afd29f...@cvs.netbsd.org>, > Kamil Rytarowski wrote: >> -=-=-=-=-=- >> >> Module Name: src >> Committed By:kamil >> Date:Sat Jun 16 18:54:52 UTC 2018 >> >> Modified Files: >> src/external/bsd/nvi/dist/common: log.c >> >> Log Message: >> Do not cause Undefined Behavior in vi(1) >> >> Replace unportable manual calculation of alignof() that causes UB, with >> a GCC extension __alignof__. > > Isn't that offsetof() instead? > > christos > Fixed! signature.asc Description: OpenPGP digital signature
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: kamil Date: Sat Jun 16 21:00:12 UTC 2018 Modified Files: src/external/bsd/nvi/dist/common: log.c Log Message: Correct previous change to CHAR_T_OFFSET The intended operation is offsetof(), not alignof(). Noted by To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/log.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/log.c diff -u src/external/bsd/nvi/dist/common/log.c:1.4 src/external/bsd/nvi/dist/common/log.c:1.5 --- src/external/bsd/nvi/dist/common/log.c:1.4 Sat Jun 16 18:54:52 2018 +++ src/external/bsd/nvi/dist/common/log.c Sat Jun 16 21:00:12 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: log.c,v 1.4 2018/06/16 18:54:52 kamil Exp $ */ +/* $NetBSD: log.c,v 1.5 2018/06/16 21:00:12 kamil Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: log.c,v 10.26 2002/03/02 23:12:13 skimo Exp (Berkeley) Date: 2002/03/02 23:12:13 "; #endif /* not lint */ #else -__RCSID("$NetBSD: log.c,v 1.4 2018/06/16 18:54:52 kamil Exp $"); +__RCSID("$NetBSD: log.c,v 1.5 2018/06/16 21:00:12 kamil Exp $"); #endif #include @@ -90,7 +90,7 @@ typedef struct { chardata[sizeof(u_char) /* type */ + sizeof(db_recno_t)]; CHAR_T str[1]; } log_t; -#define CHAR_T_OFFSET (__alignof__(log_t)) +#define CHAR_T_OFFSET (offsetof(log_t, str)) /* * log_init --
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: kamil Date: Sat Jun 16 21:00:12 UTC 2018 Modified Files: src/external/bsd/nvi/dist/common: log.c Log Message: Correct previous change to CHAR_T_OFFSET The intended operation is offsetof(), not alignof(). Noted by To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/log.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/external/bsd/nvi/dist/common
In article <20180616185452.afd29f...@cvs.netbsd.org>, Kamil Rytarowski wrote: >-=-=-=-=-=- > >Module Name: src >Committed By: kamil >Date: Sat Jun 16 18:54:52 UTC 2018 > >Modified Files: > src/external/bsd/nvi/dist/common: log.c > >Log Message: >Do not cause Undefined Behavior in vi(1) > >Replace unportable manual calculation of alignof() that causes UB, with >a GCC extension __alignof__. Isn't that offsetof() instead? christos
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: kamil Date: Sat Jun 16 18:54:52 UTC 2018 Modified Files: src/external/bsd/nvi/dist/common: log.c Log Message: Do not cause Undefined Behavior in vi(1) Replace unportable manual calculation of alignof() that causes UB, with a GCC extension __alignof__. This fixes a problem reported by UBSan with the MKSANITIZER distribution. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/log.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: kamil Date: Sat Jun 16 18:54:52 UTC 2018 Modified Files: src/external/bsd/nvi/dist/common: log.c Log Message: Do not cause Undefined Behavior in vi(1) Replace unportable manual calculation of alignof() that causes UB, with a GCC extension __alignof__. This fixes a problem reported by UBSan with the MKSANITIZER distribution. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/log.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/log.c diff -u src/external/bsd/nvi/dist/common/log.c:1.3 src/external/bsd/nvi/dist/common/log.c:1.4 --- src/external/bsd/nvi/dist/common/log.c:1.3 Sun Jan 26 21:43:45 2014 +++ src/external/bsd/nvi/dist/common/log.c Sat Jun 16 18:54:52 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: log.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */ +/* $NetBSD: log.c,v 1.4 2018/06/16 18:54:52 kamil Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: log.c,v 10.26 2002/03/02 23:12:13 skimo Exp (Berkeley) Date: 2002/03/02 23:12:13 "; #endif /* not lint */ #else -__RCSID("$NetBSD: log.c,v 1.3 2014/01/26 21:43:45 christos Exp $"); +__RCSID("$NetBSD: log.c,v 1.4 2018/06/16 18:54:52 kamil Exp $"); #endif #include @@ -90,7 +90,7 @@ typedef struct { chardata[sizeof(u_char) /* type */ + sizeof(db_recno_t)]; CHAR_T str[1]; } log_t; -#define CHAR_T_OFFSET ((char *)(((log_t*)0)->str) - (char *)0) +#define CHAR_T_OFFSET (__alignof__(log_t)) /* * log_init --
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Fri Dec 1 18:35:58 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: common.h Log Message: Remove ex_printf duplicate with ex_extern.h. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/common.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Fri Dec 1 18:35:58 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: common.h Log Message: Remove ex_printf duplicate with ex_extern.h. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/common.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/common.h diff -u src/external/bsd/nvi/dist/common/common.h:1.3 src/external/bsd/nvi/dist/common/common.h:1.4 --- src/external/bsd/nvi/dist/common/common.h:1.3 Tue Jan 7 02:14:02 2014 +++ src/external/bsd/nvi/dist/common/common.h Fri Dec 1 18:35:58 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: common.h,v 1.3 2014/01/07 02:14:02 joerg Exp $ */ +/* $NetBSD: common.h,v 1.4 2017/12/01 18:35:58 rin Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -57,8 +57,6 @@ typedef struct _tagq TAGQ; typedef struct _text TEXT; typedef struct _win WIN; -int ex_printf(SCR *, const char *, ...) __printflike(2, 3); - /* Autoindent state. */ typedef enum { C_NOTSET, C_CARATSET, C_ZEROSET } carat_t;
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Wed Nov 22 16:17:30 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: search.c Log Message: Fix missing of "search wrapped" message when searching from the last char of file, taken from nvi2: https://github.com/lichray/nvi2/commit/a59e892d23212559eb1001e5d2a312a02e357651 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/search.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/search.c diff -u src/external/bsd/nvi/dist/common/search.c:1.3 src/external/bsd/nvi/dist/common/search.c:1.4 --- src/external/bsd/nvi/dist/common/search.c:1.3 Sun Jan 26 21:43:45 2014 +++ src/external/bsd/nvi/dist/common/search.c Wed Nov 22 16:17:30 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: search.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */ +/* $NetBSD: search.c,v 1.4 2017/11/22 16:17:30 rin Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: search.c,v 10.31 2001/06/25 15:19:12 skimo Exp (Berkeley) Date: 2001/06/25 15:19:12 "; #endif /* not lint */ #else -__RCSID("$NetBSD: search.c,v 1.3 2014/01/26 21:43:45 christos Exp $"); +__RCSID("$NetBSD: search.c,v 1.4 2017/11/22 16:17:30 rin Exp $"); #endif #include @@ -148,7 +148,7 @@ f_search(SCR *sp, MARK *fm, MARK *rm, CH db_recno_t lno; regmatch_t match[1]; size_t coff, len; - int cnt, eval, rval, wrapped; + int cnt, eval, rval, wrapped = 0; CHAR_T *l; if (search_init(sp, FORWARD, ptrn, plen, eptrn, flags)) @@ -191,13 +191,14 @@ f_search(SCR *sp, MARK *fm, MARK *rm, CH return (1); } lno = 1; +wrapped = 1; } } else coff = fm->cno + 1; } btype = BUSY_ON; - for (cnt = INTERRUPT_CHECK, rval = 1, wrapped = 0;; ++lno, coff = 0) { + for (cnt = INTERRUPT_CHECK, rval = 1;; ++lno, coff = 0) { if (cnt-- == 0) { if (INTERRUPTED(sp)) break;
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Wed Nov 22 16:17:30 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: search.c Log Message: Fix missing of "search wrapped" message when searching from the last char of file, taken from nvi2: https://github.com/lichray/nvi2/commit/a59e892d23212559eb1001e5d2a312a02e357651 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/search.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Tue Nov 21 02:36:45 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: conv.c Log Message: Enable to compile & run without USE_ICONV. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/bsd/nvi/dist/common/conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/conv.c diff -u src/external/bsd/nvi/dist/common/conv.c:1.9 src/external/bsd/nvi/dist/common/conv.c:1.10 --- src/external/bsd/nvi/dist/common/conv.c:1.9 Tue Nov 21 02:11:44 2017 +++ src/external/bsd/nvi/dist/common/conv.c Tue Nov 21 02:36:45 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: conv.c,v 1.9 2017/11/21 02:11:44 rin Exp $ */ +/* $NetBSD: conv.c,v 1.10 2017/11/21 02:36:45 rin Exp $ */ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: conv.c,v 1.27 2001/08/18 21:41:41 skimo Exp (Berkeley) Date: 2001/08/18 21:41:41 "; #endif /* not lint */ #else -__RCSID("$NetBSD: conv.c,v 1.9 2017/11/21 02:11:44 rin Exp $"); +__RCSID("$NetBSD: conv.c,v 1.10 2017/11/21 02:36:45 rin Exp $"); #endif #include @@ -39,14 +39,13 @@ __RCSID("$NetBSD: conv.c,v 1.9 2017/11/2 #define LANGCODESET nl_langinfo(CODESET) #else -typedef int iconv_t; - #define LANGCODESET "" #endif #include #ifdef USE_WIDECHAR +#ifdef USE_ICONV static int raw2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw, size_t *tolen, const CHAR_T **dst) @@ -67,6 +66,7 @@ raw2int(SCR *sp, const char * str, ssize return 0; } +#endif #ifndef ERROR_ON_CONVERT #define HANDLE_ICONV_ERROR(o, i, ol, il) do {\ @@ -104,8 +104,6 @@ raw2int(SCR *sp, const char * str, ssize }\ src = buffer; \ } while (0) -#else -#define CONVERT(str, left, src, len) #endif static int @@ -120,10 +118,12 @@ default_char2int(SCR *sp, const char * s size_t n; ssize_t nlen = len; const char *src = (const char *)str; +int error = 1; +#ifdef USE_ICONV iconv_t id = (iconv_t)-1; char buffer[CONV_BUFFER_SIZE]; size_t left = len; -int error = 1; +#endif MEMSET(, 0, 1); BINC_RETW(NULL, *tostr, *blen, nlen); @@ -153,24 +153,30 @@ default_char2int(SCR *sp, const char * s nlen += 256; BINC_GOTOW(NULL, *tostr, *blen, nlen); } +#ifdef USE_ICONV if (id != (iconv_t)-1 && j == len && left) { CONVERT(str, left, src, len); j = 0; } +#endif } *tolen = i; +#ifdef USE_ICONV if (id != (iconv_t)-1) iconv_close(id); +#endif *dst = cw->bp1; return 0; -err: alloc_err: -*tolen = i; +#ifdef USE_ICONV +err: if (id != (iconv_t)-1) iconv_close(id); +#endif +*tolen = i; *dst = cw->bp1; return error; @@ -197,6 +203,7 @@ cs_char2int(SCR *sp, const char * str, s return default_char2int(sp, str, len, cw, tolen, dst, LANGCODESET); } +#ifdef USE_ICONV static int CHAR_T_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, size_t *tolen, const char **dst) @@ -238,13 +245,13 @@ int2raw(SCR *sp, const CHAR_T * str, ssi return 0; } +#endif static int default_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, size_t *tolen, const char **pdst, const char *enc) { size_t i, j = 0; -int offset = 0; char **tostr = (char **)(void *)>bp1; size_t *blen = >blen1; mbstate_t mbs; @@ -252,8 +259,11 @@ default_int2char(SCR *sp, const CHAR_T * ssize_t nlen = len + MB_CUR_MAX; char *dst; size_t buflen; +#ifdef USE_ICONV +int offset = 0; char buffer[CONV_BUFFER_SIZE]; iconv_t id = (iconv_t)-1; +#endif /* convert first len bytes of buffer and append it to cw->bp * len is adjusted => 0 @@ -279,11 +289,8 @@ default_int2char(SCR *sp, const CHAR_T * offset = cw->blen1 - outleft; \ } while (ret != 0); \ } while (0) -#else -#define CONVERT2(_buffer, lenp, cw, offset) #endif - MEMSET(, 0, 1); BINC_RETC(NULL, *tostr, *blen, nlen); dst = *tostr; buflen = *blen; @@ -305,9 +312,12 @@ default_int2char(SCR *sp, const CHAR_T * HANDLE_MBR_ERROR(n, mbs, dst[j], w); j += n; if (buflen < j + MB_CUR_MAX) { +#ifdef USE_ICONV if (id != (iconv_t)-1) { CONVERT2(buffer, , cw, offset); - } else { + } else +#endif + { nlen += 256; BINC_RETC(NULL, *tostr, *blen, nlen); dst = *tostr; buflen = *blen; @@ -319,25 +329,28 @@ default_int2char(SCR *sp, const CHAR_T * j += n - 1;/* don't count NUL at the end */ *tolen = j; +#ifdef USE_ICONV if (id != (iconv_t)-1) { CONVERT2(buffer, , cw, offset); CONVERT2(NULL, NULL, cw, offset); /* back to the initial state */ *tolen = offset; iconv_close(id); } +#endif *pdst = cw->bp1; return 0; -err: +#ifdef
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Tue Nov 21 02:36:45 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: conv.c Log Message: Enable to compile & run without USE_ICONV. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/bsd/nvi/dist/common/conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Tue Nov 21 02:11:44 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: conv.c Log Message: Fix resource leaks due to missing of iconv_close(3). To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/bsd/nvi/dist/common/conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Tue Nov 21 02:11:44 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: conv.c Log Message: Fix resource leaks due to missing of iconv_close(3). To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/bsd/nvi/dist/common/conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/conv.c diff -u src/external/bsd/nvi/dist/common/conv.c:1.8 src/external/bsd/nvi/dist/common/conv.c:1.9 --- src/external/bsd/nvi/dist/common/conv.c:1.8 Tue Nov 21 02:00:29 2017 +++ src/external/bsd/nvi/dist/common/conv.c Tue Nov 21 02:11:44 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: conv.c,v 1.8 2017/11/21 02:00:29 rin Exp $ */ +/* $NetBSD: conv.c,v 1.9 2017/11/21 02:11:44 rin Exp $ */ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: conv.c,v 1.27 2001/08/18 21:41:41 skimo Exp (Berkeley) Date: 2001/08/18 21:41:41 "; #endif /* not lint */ #else -__RCSID("$NetBSD: conv.c,v 1.8 2017/11/21 02:00:29 rin Exp $"); +__RCSID("$NetBSD: conv.c,v 1.9 2017/11/21 02:11:44 rin Exp $"); #endif #include @@ -151,7 +151,7 @@ default_char2int(SCR *sp, const char * s j += n; if (++i >= *blen) { nlen += 256; - BINC_RETW(NULL, *tostr, *blen, nlen); + BINC_GOTOW(NULL, *tostr, *blen, nlen); } if (id != (iconv_t)-1 && j == len && left) { CONVERT(str, left, src, len); @@ -167,6 +167,7 @@ default_char2int(SCR *sp, const char * s return 0; err: +alloc_err: *tolen = i; if (id != (iconv_t)-1) iconv_close(id); @@ -269,7 +270,7 @@ default_int2char(SCR *sp, const CHAR_T * char *obp = (char *)cw->bp1 + offset; \ if (cw->blen1 < offset + MB_CUR_MAX) { \ nlen += 256; \ - BINC_RETC(NULL, cw->bp1, cw->blen1, nlen); \ + BINC_GOTOC(NULL, cw->bp1, cw->blen1, nlen); \ } \ errno = 0; \ ret = iconv(id, , lenp, , ); \ @@ -322,14 +323,18 @@ default_int2char(SCR *sp, const CHAR_T * CONVERT2(buffer, , cw, offset); CONVERT2(NULL, NULL, cw, offset); /* back to the initial state */ *tolen = offset; + iconv_close(id); } *pdst = cw->bp1; return 0; err: +alloc_err: *tolen = j; - +if (id != (iconv_t)-1) { + iconv_close(id); +} *pdst = cw->bp1; return 1;
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Tue Nov 21 02:04:39 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: mem.h Log Message: Fix -Wsign-compare issue for BINC_GOTO in a similar manner to BINC_RET. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/nvi/dist/common/mem.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Tue Nov 21 02:04:39 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: mem.h Log Message: Fix -Wsign-compare issue for BINC_GOTO in a similar manner to BINC_RET. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/nvi/dist/common/mem.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/mem.h diff -u src/external/bsd/nvi/dist/common/mem.h:1.2 src/external/bsd/nvi/dist/common/mem.h:1.3 --- src/external/bsd/nvi/dist/common/mem.h:1.2 Fri Nov 22 15:52:05 2013 +++ src/external/bsd/nvi/dist/common/mem.h Tue Nov 21 02:04:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.h,v 1.2 2013/11/22 15:52:05 christos Exp $ */ +/* $NetBSD: mem.h,v 1.3 2017/11/21 02:04:39 rin Exp $ */ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -23,7 +23,7 @@ #define BINC_GOTO(sp, type, lp, llen, nlen) {\ CHECK_TYPE(type *, lp) \ void *L__bincp; \ - if ((nlen) > llen) { \ + if ((size_t)(nlen) > llen) { \ if ((L__bincp = binc(sp, lp, &(llen), nlen)) == NULL) \ goto alloc_err; \ /* \
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Tue Nov 21 02:00:29 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: conv.c Log Message: Fix use of uninitialized variable, found by clang. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/external/bsd/nvi/dist/common/conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/conv.c diff -u src/external/bsd/nvi/dist/common/conv.c:1.7 src/external/bsd/nvi/dist/common/conv.c:1.8 --- src/external/bsd/nvi/dist/common/conv.c:1.7 Mon Nov 13 04:21:55 2017 +++ src/external/bsd/nvi/dist/common/conv.c Tue Nov 21 02:00:29 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: conv.c,v 1.7 2017/11/13 04:21:55 rin Exp $ */ +/* $NetBSD: conv.c,v 1.8 2017/11/21 02:00:29 rin Exp $ */ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: conv.c,v 1.27 2001/08/18 21:41:41 skimo Exp (Berkeley) Date: 2001/08/18 21:41:41 "; #endif /* not lint */ #else -__RCSID("$NetBSD: conv.c,v 1.7 2017/11/13 04:21:55 rin Exp $"); +__RCSID("$NetBSD: conv.c,v 1.8 2017/11/21 02:00:29 rin Exp $"); #endif #include @@ -242,7 +242,7 @@ static int default_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, size_t *tolen, const char **pdst, const char *enc) { -size_t i, j; +size_t i, j = 0; int offset = 0; char **tostr = (char **)(void *)>bp1; size_t *blen = >blen1;
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Tue Nov 21 02:00:29 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: conv.c Log Message: Fix use of uninitialized variable, found by clang. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/external/bsd/nvi/dist/common/conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Mon Nov 13 04:21:55 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: conv.c Log Message: Protect iconv stuffs by USE_WIDECHAR in addition to USE_ICONV. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/nvi/dist/common/conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/conv.c diff -u src/external/bsd/nvi/dist/common/conv.c:1.6 src/external/bsd/nvi/dist/common/conv.c:1.7 --- src/external/bsd/nvi/dist/common/conv.c:1.6 Fri Nov 10 18:08:11 2017 +++ src/external/bsd/nvi/dist/common/conv.c Mon Nov 13 04:21:55 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: conv.c,v 1.6 2017/11/10 18:08:11 rin Exp $ */ +/* $NetBSD: conv.c,v 1.7 2017/11/13 04:21:55 rin Exp $ */ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: conv.c,v 1.27 2001/08/18 21:41:41 skimo Exp (Berkeley) Date: 2001/08/18 21:41:41 "; #endif /* not lint */ #else -__RCSID("$NetBSD: conv.c,v 1.6 2017/11/10 18:08:11 rin Exp $"); +__RCSID("$NetBSD: conv.c,v 1.7 2017/11/13 04:21:55 rin Exp $"); #endif #include @@ -33,7 +33,7 @@ __RCSID("$NetBSD: conv.c,v 1.6 2017/11/1 #include "common.h" -#ifdef USE_ICONV +#if defined(USE_WIDECHAR) && defined(USE_ICONV) #include #include @@ -365,11 +365,11 @@ conv_init (SCR *orig, SCR *sp) sp->conv.file2int = fe_char2int; sp->conv.int2file = fe_int2char; sp->conv.input2int = ie_char2int; -#endif #ifdef USE_ICONV o_set(sp, O_FILEENCODING, OS_STRDUP, nl_langinfo(CODESET), 0); o_set(sp, O_INPUTENCODING, OS_STRDUP, nl_langinfo(CODESET), 0); #endif +#endif } }
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Mon Nov 13 04:21:55 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: conv.c Log Message: Protect iconv stuffs by USE_WIDECHAR in addition to USE_ICONV. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/nvi/dist/common/conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Mon Nov 13 01:34:59 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: multibyte.h Log Message: Remove duplicate definition for ISUPPER. No binary changes. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/multibyte.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Mon Nov 13 01:34:59 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: multibyte.h Log Message: Remove duplicate definition for ISUPPER. No binary changes. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/multibyte.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/multibyte.h diff -u src/external/bsd/nvi/dist/common/multibyte.h:1.3 src/external/bsd/nvi/dist/common/multibyte.h:1.4 --- src/external/bsd/nvi/dist/common/multibyte.h:1.3 Sun Oct 29 15:29:34 2017 +++ src/external/bsd/nvi/dist/common/multibyte.h Mon Nov 13 01:34:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: multibyte.h,v 1.3 2017/10/29 15:29:34 christos Exp $ */ +/* $NetBSD: multibyte.h,v 1.4 2017/11/13 01:34:59 rin Exp $ */ #ifndef MULTIBYTE_H #define MULTIBYTE_H @@ -41,7 +41,6 @@ typedef wchar_t CHAR_T; typedef wint_t ARG_CHAR_T; typedef wint_t UCHAR_T; -#define ISUPPER iswupper #define STRLEN wcslen #define STRTOL wcstol #define STRTOUL wcstoul @@ -75,7 +74,6 @@ typedef char CHAR_T; typedef int ARG_CHAR_T; typedef unsigned char UCHAR_T; -#define ISUPPER isupper #define STRLEN strlen #define STRTOL strtol #define STRTOUL strtoul
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Sun Nov 12 15:26:34 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: util.c Log Message: No need to cast endp in both cases of USE_WIDECHAR == "yes" nor "no". Note that RCHAR_T is intended to use for bundled regex, not for nvi itself. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/util.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Sun Nov 12 15:26:34 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: util.c Log Message: No need to cast endp in both cases of USE_WIDECHAR == "yes" nor "no". Note that RCHAR_T is intended to use for bundled regex, not for nvi itself. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/util.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/util.c diff -u src/external/bsd/nvi/dist/common/util.c:1.3 src/external/bsd/nvi/dist/common/util.c:1.4 --- src/external/bsd/nvi/dist/common/util.c:1.3 Sun Jan 26 21:43:45 2014 +++ src/external/bsd/nvi/dist/common/util.c Sun Nov 12 15:26:33 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */ +/* $NetBSD: util.c,v 1.4 2017/11/12 15:26:33 rin Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: util.c,v 10.22 2001/06/25 15:19:12 skimo Exp (Berkeley) Date: 2001/06/25 15:19:12 "; #endif /* not lint */ #else -__RCSID("$NetBSD: util.c,v 1.3 2014/01/26 21:43:45 christos Exp $"); +__RCSID("$NetBSD: util.c,v 1.4 2017/11/12 15:26:33 rin Exp $"); #endif #include @@ -169,7 +169,7 @@ enum nresult nget_uslong(SCR *sp, u_long *valp, const CHAR_T *p, CHAR_T **endp, int base) { errno = 0; - *valp = STRTOUL(p, (RCHAR_T **)endp, base); + *valp = STRTOUL(p, endp, base); if (errno == 0) return (NUM_OK); if (errno == ERANGE && *valp == ULONG_MAX) @@ -187,7 +187,7 @@ enum nresult nget_slong(SCR *sp, long int *valp, const CHAR_T *p, CHAR_T **endp, int base) { errno = 0; - *valp = STRTOL(p, (RCHAR_T **)endp, base); + *valp = STRTOL(p, endp, base); if (errno == 0) return (NUM_OK); if (errno == ERANGE) {
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Sun Nov 12 15:23:51 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: put.c Log Message: Fix argument type of put() in common_extern.h To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/put.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/put.c diff -u src/external/bsd/nvi/dist/common/put.c:1.4 src/external/bsd/nvi/dist/common/put.c:1.5 --- src/external/bsd/nvi/dist/common/put.c:1.4 Sun Jan 26 21:43:45 2014 +++ src/external/bsd/nvi/dist/common/put.c Sun Nov 12 15:23:51 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: put.c,v 1.4 2014/01/26 21:43:45 christos Exp $ */ +/* $NetBSD: put.c,v 1.5 2017/11/12 15:23:51 rin Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: put.c,v 10.18 2001/06/25 15:19:11 skimo Exp (Berkeley) Date: 2001/06/25 15:19:11 "; #endif /* not lint */ #else -__RCSID("$NetBSD: put.c,v 1.4 2014/01/26 21:43:45 christos Exp $"); +__RCSID("$NetBSD: put.c,v 1.5 2017/11/12 15:23:51 rin Exp $"); #endif #include @@ -35,7 +35,7 @@ __RCSID("$NetBSD: put.c,v 1.4 2014/01/26 * put -- * Put text buffer contents into the file. * - * PUBLIC: int put __P((SCR *, CB *, CHAR_T *, MARK *, MARK *, int)); + * PUBLIC: int put __P((SCR *, CB *, ARG_CHAR_T *, MARK *, MARK *, int)); */ int put(SCR *sp, CB *cbp, ARG_CHAR_T *namep, MARK *cp, MARK *rp, int append)
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Sun Nov 12 15:23:51 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: put.c Log Message: Fix argument type of put() in common_extern.h To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/put.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Fri Nov 10 20:01:11 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: recover.c Log Message: Instead of opening the file and using popen(3), pass the file descriptor to sendmail directory. Idea and code from Todd Miller. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/external/bsd/nvi/dist/common/recover.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/recover.c diff -u src/external/bsd/nvi/dist/common/recover.c:1.10 src/external/bsd/nvi/dist/common/recover.c:1.11 --- src/external/bsd/nvi/dist/common/recover.c:1.10 Fri Nov 10 11:35:54 2017 +++ src/external/bsd/nvi/dist/common/recover.c Fri Nov 10 15:01:11 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: recover.c,v 1.10 2017/11/10 16:35:54 christos Exp $ */ +/* $NetBSD: recover.c,v 1.11 2017/11/10 20:01:11 christos Exp $ */ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,12 +16,13 @@ static const char sccsid[] = "Id: recover.c,v 10.31 2001/11/01 15:24:44 skimo Exp (Berkeley) Date: 2001/11/01 15:24:44 "; #endif /* not lint */ #else -__RCSID("$NetBSD: recover.c,v 1.10 2017/11/10 16:35:54 christos Exp $"); +__RCSID("$NetBSD: recover.c,v 1.11 2017/11/10 20:01:11 christos Exp $"); #endif #include #include /* XXX: param.h may not have included types.h */ #include +#include #include /* @@ -116,7 +117,7 @@ __RCSID("$NetBSD: recover.c,v 1.10 2017/ #define VI_PHEADER "X-vi-recover-path: " static int rcv_copy(SCR *, int, char *); -static void rcv_email(SCR *, const char *); +static void rcv_email(SCR *, int fd); static char *rcv_gets(char *, size_t, int); static int rcv_mailfile(SCR *, int, char *); static int rcv_mktemp(SCR *, char *, const char *, int); @@ -290,7 +291,7 @@ rcv_sync(SCR *sp, u_int flags) /* REQUEST: send email. */ if (LF_ISSET(RCV_EMAIL)) - rcv_email(sp, ep->rcv_mpath); + rcv_email(sp, ep->rcv_fd); } /* @@ -470,7 +471,7 @@ wout: *t2++ = '\n'; } if (issync) { - rcv_email(sp, mpath); + rcv_email(sp, fd); if (close(fd)) { werr: msgq(sp, M_SYSERR, "065|Recovery file"); goto err; @@ -885,12 +886,10 @@ rcv_mktemp(SCR *sp, char *path, const ch * Send email. */ static void -rcv_email(SCR *sp, const char *fname) +rcv_email(SCR *sp, int fd) { struct stat sb; - char buf[BUFSIZ]; - FILE *fin, *fout; - size_t l; + pid_t pid; if (_PATH_SENDMAIL[0] != '/' || stat(_PATH_SENDMAIL, ) == -1) { msgq_str(sp, M_SYSERR, @@ -905,28 +904,26 @@ rcv_email(SCR *sp, const char *fname) * for the recipients instead of specifying them some other * way. */ - if ((fin = fopen(fname, "refl")) == NULL) { - msgq_str(sp, M_SYSERR, - fname, "325|cannot open: %s"); - return; - } - - if (!checkok(fileno(fin))) { - (void)fclose(fin); - return; - } - - fout = popen(_PATH_SENDMAIL " -t", "w"); - if (fout == NULL) { - msgq_str(sp, M_SYSERR, - _PATH_SENDMAIL, "326|cannot execute sendmail: %s"); - fclose(fin); - return; + switch (pid = fork()) { + case -1:/* Error. */ + msgq(sp, M_SYSERR, "fork"); + break; + case 0: /* Sendmail. */ + if (lseek(fd, 0, SEEK_SET) == -1) { + msgq(sp, M_SYSERR, "lseek"); + _exit(127); + } + if (fd != STDIN_FILENO) { + (void)dup2(fd, STDIN_FILENO); + (void)close(fd); + } + execl(_PATH_SENDMAIL, "sendmail", "-t", NULL); + msgq(sp, M_SYSERR, _PATH_SENDMAIL); + _exit(127); + default:/* Parent. */ + while (waitpid(pid, NULL, 0) == -1 && errno == EINTR) + continue; + break; } - while ((l = fread(buf, 1, sizeof(buf), fin)) != 0) - (void)fwrite(buf, 1, l, fout); - - (void)fclose(fin); - (void)pclose(fout); }
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Fri Nov 10 20:01:11 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: recover.c Log Message: Instead of opening the file and using popen(3), pass the file descriptor to sendmail directory. Idea and code from Todd Miller. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/external/bsd/nvi/dist/common/recover.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Fri Nov 10 18:08:11 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: conv.c Log Message: Restore the initial state at the end of line. This matters for stateful encodings like iso-2022-jp. Fix taken from yamt via nvi2. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/nvi/dist/common/conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/conv.c diff -u src/external/bsd/nvi/dist/common/conv.c:1.5 src/external/bsd/nvi/dist/common/conv.c:1.6 --- src/external/bsd/nvi/dist/common/conv.c:1.5 Mon Nov 6 03:02:22 2017 +++ src/external/bsd/nvi/dist/common/conv.c Fri Nov 10 18:08:11 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: conv.c,v 1.5 2017/11/06 03:02:22 rin Exp $ */ +/* $NetBSD: conv.c,v 1.6 2017/11/10 18:08:11 rin Exp $ */ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: conv.c,v 1.27 2001/08/18 21:41:41 skimo Exp (Berkeley) Date: 2001/08/18 21:41:41 "; #endif /* not lint */ #else -__RCSID("$NetBSD: conv.c,v 1.5 2017/11/06 03:02:22 rin Exp $"); +__RCSID("$NetBSD: conv.c,v 1.6 2017/11/10 18:08:11 rin Exp $"); #endif #include @@ -260,10 +260,11 @@ default_int2char(SCR *sp, const CHAR_T * * cw->bp is grown as required */ #ifdef USE_ICONV -#define CONVERT2(len, cw, offset) \ +#define CONVERT2(_buffer, lenp, cw, offset)\ do {\ - const char *bp = buffer; \ - while (len != 0) { \ + const char *bp = _buffer; \ + size_t ret; \ + do {\ size_t outleft = cw->blen1 - offset; \ char *obp = (char *)cw->bp1 + offset; \ if (cw->blen1 < offset + MB_CUR_MAX) { \ @@ -271,14 +272,14 @@ default_int2char(SCR *sp, const CHAR_T * BINC_RETC(NULL, cw->bp1, cw->blen1, nlen); \ } \ errno = 0; \ - if (iconv(id, , , , ) == (size_t)-1 && \ - errno != E2BIG) \ + ret = iconv(id, , lenp, , ); \ + if (ret == (size_t)-1 && errno != E2BIG) \ HANDLE_ICONV_ERROR(obp, bp, outleft, len); \ offset = cw->blen1 - outleft; \ - } \ + } while (ret != 0); \ } while (0) #else -#define CONVERT2(len, cw, offset) +#define CONVERT2(_buffer, lenp, cw, offset) #endif @@ -304,7 +305,7 @@ default_int2char(SCR *sp, const CHAR_T * j += n; if (buflen < j + MB_CUR_MAX) { if (id != (iconv_t)-1) { - CONVERT2(j, cw, offset); + CONVERT2(buffer, , cw, offset); } else { nlen += 256; BINC_RETC(NULL, *tostr, *blen, nlen); @@ -318,7 +319,8 @@ default_int2char(SCR *sp, const CHAR_T * *tolen = j; if (id != (iconv_t)-1) { - CONVERT2(j, cw, offset); + CONVERT2(buffer, , cw, offset); + CONVERT2(NULL, NULL, cw, offset); /* back to the initial state */ *tolen = offset; }
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Fri Nov 10 18:08:11 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: conv.c Log Message: Restore the initial state at the end of line. This matters for stateful encodings like iso-2022-jp. Fix taken from yamt via nvi2. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/nvi/dist/common/conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Fri Nov 10 16:35:54 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: recover.c Log Message: make the checkok test stricter to avoid races, and use O_REGULAR. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/bsd/nvi/dist/common/recover.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/recover.c diff -u src/external/bsd/nvi/dist/common/recover.c:1.9 src/external/bsd/nvi/dist/common/recover.c:1.10 --- src/external/bsd/nvi/dist/common/recover.c:1.9 Sat Nov 4 10:20:12 2017 +++ src/external/bsd/nvi/dist/common/recover.c Fri Nov 10 11:35:54 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: recover.c,v 1.9 2017/11/04 14:20:12 christos Exp $ */ +/* $NetBSD: recover.c,v 1.10 2017/11/10 16:35:54 christos Exp $ */ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: recover.c,v 10.31 2001/11/01 15:24:44 skimo Exp (Berkeley) Date: 2001/11/01 15:24:44 "; #endif /* not lint */ #else -__RCSID("$NetBSD: recover.c,v 1.9 2017/11/04 14:20:12 christos Exp $"); +__RCSID("$NetBSD: recover.c,v 1.10 2017/11/10 16:35:54 christos Exp $"); #endif #include @@ -121,6 +121,10 @@ static char *rcv_gets(char *, size_t, in static int rcv_mailfile(SCR *, int, char *); static int rcv_mktemp(SCR *, char *, const char *, int); +#ifndef O_REGULAR +#define O_REGULAR O_NONBLOCK +#endif + /* * rcv_tmp -- * Build a file name that will be used as the recovery file. @@ -487,14 +491,19 @@ err: if (!issync) * This is simpler than checking for getuid() == st.st_uid and we want * to preserve the functionality that root can recover anything which * means that root should know better and be careful. + * + * Checking the mode is racy though (someone can chmod between the + * open and the stat call, so also check for uid match or root. */ static int checkok(int fd) { struct stat sb; + uid_t uid = getuid(); return fstat(fd, ) != -1 && S_ISREG(sb.st_mode) && - (sb.st_mode & (S_IRWXG|S_IRWXO)) == 0; + (sb.st_mode & (S_IRWXG|S_IRWXO)) == 0 && + (uid == 0 || uid == sb.st_uid); } /* @@ -659,7 +668,7 @@ rcv_read(SCR *sp, FREF *frp) * if we're using fcntl(2), there's no way to lock a file * descriptor that's not open for writing. */ - if ((fd = open(recpath, O_RDWR|O_NONBLOCK|O_NOFOLLOW|O_CLOEXEC, + if ((fd = open(recpath, O_RDWR|O_REGULAR|O_NOFOLLOW|O_CLOEXEC, 0)) == -1) continue;
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Fri Nov 10 16:35:54 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: recover.c Log Message: make the checkok test stricter to avoid races, and use O_REGULAR. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/bsd/nvi/dist/common/recover.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Mon Nov 6 03:21:13 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: options.c Log Message: Entries of abbrev[] should be sorted for bsearch(3) to work. Fix the problem that option abbreviation "fe" is neglected. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/options.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Mon Nov 6 03:21:13 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: options.c Log Message: Entries of abbrev[] should be sorted for bsearch(3) to work. Fix the problem that option abbreviation "fe" is neglected. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/options.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/options.c diff -u src/external/bsd/nvi/dist/common/options.c:1.4 src/external/bsd/nvi/dist/common/options.c:1.5 --- src/external/bsd/nvi/dist/common/options.c:1.4 Mon Nov 6 03:17:37 2017 +++ src/external/bsd/nvi/dist/common/options.c Mon Nov 6 03:21:13 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: options.c,v 1.4 2017/11/06 03:17:37 rin Exp $ */ +/* $NetBSD: options.c,v 1.5 2017/11/06 03:21:13 rin Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: options.c,v 10.65 2002/01/18 22:34:43 skimo Exp (Berkeley) Date: 2002/01/18 22:34:43 "; #endif /* not lint */ #else -__RCSID("$NetBSD: options.c,v 1.4 2017/11/06 03:17:37 rin Exp $"); +__RCSID("$NetBSD: options.c,v 1.5 2017/11/06 03:21:13 rin Exp $"); #endif #include @@ -275,10 +275,10 @@ static OABBREV const abbrev[] = { {L("ed"), O_EDCOMPATIBLE}, /* 4BSD */ {L("et"), O_EXPANDTAB}, /* NetBSD 5.0 */ {L("ex"), O_EXRC}, /* System V (undocumented) */ + {L("fe"), O_FILEENCODING}, #ifdef GTAGS {L("gt"), O_GTAGSMODE}, /* FreeBSD, NetBSD */ #endif - {L("fe"), O_FILEENCODING}, {L("ht"), O_HARDTABS}, /* 4BSD */ {L("ic"), O_IGNORECASE}, /* 4BSD */ {L("ie"), O_INPUTENCODING},
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Mon Nov 6 03:17:37 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: options.c Log Message: Fix corruption in numbering of options without GTAGS compile-time option. Now nvi works without GTAGS. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/options.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/options.c diff -u src/external/bsd/nvi/dist/common/options.c:1.3 src/external/bsd/nvi/dist/common/options.c:1.4 --- src/external/bsd/nvi/dist/common/options.c:1.3 Sun Jan 26 21:43:45 2014 +++ src/external/bsd/nvi/dist/common/options.c Mon Nov 6 03:17:37 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: options.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */ +/* $NetBSD: options.c,v 1.4 2017/11/06 03:17:37 rin Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: options.c,v 10.65 2002/01/18 22:34:43 skimo Exp (Berkeley) Date: 2002/01/18 22:34:43 "; #endif /* not lint */ #else -__RCSID("$NetBSD: options.c,v 1.3 2014/01/26 21:43:45 christos Exp $"); +__RCSID("$NetBSD: options.c,v 1.4 2017/11/06 03:17:37 rin Exp $"); #endif #include @@ -100,9 +100,11 @@ OPTLIST const optlist[] = { {L("fileencoding"),f_encoding, OPT_STR, OPT_WC}, /* O_FLASH HPUX */ {L("flash"), NULL, OPT_1BOOL, 0}, -#ifdef GTAGS /* O_GTAGSMODE FreeBSD/NetBSD */ +#ifdef GTAGS {L("gtagsmode"),NULL, OPT_0BOOL, 0}, +#else + {L("gtagsmode"),NULL, OPT_0BOOL, OPT_NDISP|OPT_NOSAVE|OPT_NOSET}, #endif /* O_HARDTABS 4BSD */ {L("hardtabs"), NULL, OPT_NUM, 0},
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Mon Nov 6 03:17:37 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: options.c Log Message: Fix corruption in numbering of options without GTAGS compile-time option. Now nvi works without GTAGS. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/options.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Mon Nov 6 03:03:54 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: msg.c Log Message: Fix bogus file location in percentage. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/msg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Mon Nov 6 03:03:54 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: msg.c Log Message: Fix bogus file location in percentage. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/msg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/msg.c diff -u src/external/bsd/nvi/dist/common/msg.c:1.3 src/external/bsd/nvi/dist/common/msg.c:1.4 --- src/external/bsd/nvi/dist/common/msg.c:1.3 Sun Jan 26 21:43:45 2014 +++ src/external/bsd/nvi/dist/common/msg.c Mon Nov 6 03:03:54 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: msg.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */ +/* $NetBSD: msg.c,v 1.4 2017/11/06 03:03:54 rin Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: msg.c,v 10.61 2003/07/18 23:17:30 skimo Exp (Berkeley) Date: 2003/07/18 23:17:30 "; #endif /* not lint */ #else -__RCSID("$NetBSD: msg.c,v 1.3 2014/01/26 21:43:45 christos Exp $"); +__RCSID("$NetBSD: msg.c,v 1.4 2017/11/06 03:03:54 rin Exp $"); #endif #include @@ -657,7 +657,8 @@ msgq_status(SCR *sp, db_recno_t lno, u_i p += len; } else { t = msg_cat(sp, "027|line %lu of %lu [%ld%%]", ); - (void)sprintf(p, t, lno, last, (lno * 100) / last); + (void)sprintf(p, t, lno, last, + (long)((lno * 100) / last)); p += strlen(p); } } else {
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Mon Nov 6 03:02:22 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: conv.c Log Message: Fix buffer overrun caused by lines longer than CONV_BUFFER_SIZE. Take care of errno == E2BIG case of iconv(3) appropriately. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/conv.c diff -u src/external/bsd/nvi/dist/common/conv.c:1.4 src/external/bsd/nvi/dist/common/conv.c:1.5 --- src/external/bsd/nvi/dist/common/conv.c:1.4 Sun Jan 26 21:43:45 2014 +++ src/external/bsd/nvi/dist/common/conv.c Mon Nov 6 03:02:22 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: conv.c,v 1.4 2014/01/26 21:43:45 christos Exp $ */ +/* $NetBSD: conv.c,v 1.5 2017/11/06 03:02:22 rin Exp $ */ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: conv.c,v 1.27 2001/08/18 21:41:41 skimo Exp (Berkeley) Date: 2001/08/18 21:41:41 "; #endif /* not lint */ #else -__RCSID("$NetBSD: conv.c,v 1.4 2014/01/26 21:43:45 christos Exp $"); +__RCSID("$NetBSD: conv.c,v 1.5 2017/11/06 03:02:22 rin Exp $"); #endif #include @@ -96,7 +96,7 @@ raw2int(SCR *sp, const char * str, ssize outleft = CONV_BUFFER_SIZE; \ errno = 0; \ if (iconv(id, (const char **), , , ) \ - == (size_t)-1 /* && errno != E2BIG */) \ + == (size_t)-1 && errno != E2BIG)\ HANDLE_ICONV_ERROR(bp, str, outleft, left); \ if ((len = CONV_BUFFER_SIZE - outleft) == 0) { \ error = -left; \
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: rin Date: Mon Nov 6 03:02:22 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: conv.c Log Message: Fix buffer overrun caused by lines longer than CONV_BUFFER_SIZE. Take care of errno == E2BIG case of iconv(3) appropriately. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Sat Nov 4 14:20:13 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: recover.c Log Message: Don't use popenve() for portability; forking an extra shell here is not an issue. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/bsd/nvi/dist/common/recover.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Sat Nov 4 14:20:13 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: recover.c Log Message: Don't use popenve() for portability; forking an extra shell here is not an issue. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/bsd/nvi/dist/common/recover.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/recover.c diff -u src/external/bsd/nvi/dist/common/recover.c:1.8 src/external/bsd/nvi/dist/common/recover.c:1.9 --- src/external/bsd/nvi/dist/common/recover.c:1.8 Sat Nov 4 02:15:56 2017 +++ src/external/bsd/nvi/dist/common/recover.c Sat Nov 4 10:20:12 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: recover.c,v 1.8 2017/11/04 06:15:56 christos Exp $ */ +/* $NetBSD: recover.c,v 1.9 2017/11/04 14:20:12 christos Exp $ */ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: recover.c,v 10.31 2001/11/01 15:24:44 skimo Exp (Berkeley) Date: 2001/11/01 15:24:44 "; #endif /* not lint */ #else -__RCSID("$NetBSD: recover.c,v 1.8 2017/11/04 06:15:56 christos Exp $"); +__RCSID("$NetBSD: recover.c,v 1.9 2017/11/04 14:20:12 christos Exp $"); #endif #include @@ -871,8 +871,6 @@ rcv_mktemp(SCR *sp, char *path, const ch return (fd); } -extern char **environ; - /* * rcv_email -- * Send email. @@ -883,7 +881,6 @@ rcv_email(SCR *sp, const char *fname) struct stat sb; char buf[BUFSIZ]; FILE *fin, *fout; - const char *argv[4]; size_t l; if (_PATH_SENDMAIL[0] != '/' || stat(_PATH_SENDMAIL, ) == -1) { @@ -910,12 +907,7 @@ rcv_email(SCR *sp, const char *fname) return; } - argv[0] = _PATH_SENDMAIL; - argv[1] = "-t"; - argv[2] = fname; - argv[3] = NULL; - - fout = popenve(_PATH_SENDMAIL, __UNCONST(argv), environ, "w"); + fout = popen(_PATH_SENDMAIL " -t", "w"); if (fout == NULL) { msgq_str(sp, M_SYSERR, _PATH_SENDMAIL, "326|cannot execute sendmail: %s");
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Sat Nov 4 06:15:56 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: recover.c Log Message: oops, accidendally committed an earlier non-working version; fixed. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/external/bsd/nvi/dist/common/recover.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Sat Nov 4 06:15:56 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: recover.c Log Message: oops, accidendally committed an earlier non-working version; fixed. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/external/bsd/nvi/dist/common/recover.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/recover.c diff -u src/external/bsd/nvi/dist/common/recover.c:1.7 src/external/bsd/nvi/dist/common/recover.c:1.8 --- src/external/bsd/nvi/dist/common/recover.c:1.7 Sat Nov 4 02:12:26 2017 +++ src/external/bsd/nvi/dist/common/recover.c Sat Nov 4 02:15:56 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: recover.c,v 1.7 2017/11/04 06:12:26 christos Exp $ */ +/* $NetBSD: recover.c,v 1.8 2017/11/04 06:15:56 christos Exp $ */ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: recover.c,v 10.31 2001/11/01 15:24:44 skimo Exp (Berkeley) Date: 2001/11/01 15:24:44 "; #endif /* not lint */ #else -__RCSID("$NetBSD: recover.c,v 1.7 2017/11/04 06:12:26 christos Exp $"); +__RCSID("$NetBSD: recover.c,v 1.8 2017/11/04 06:15:56 christos Exp $"); #endif #include @@ -901,11 +901,11 @@ rcv_email(SCR *sp, const char *fname) */ if ((fin = fopen(fname, "refl")) == NULL) { msgq_str(sp, M_SYSERR, - fname, "071|cannot open: %s"); + fname, "325|cannot open: %s"); return; } - if (!checkok(fname)) { + if (!checkok(fileno(fin))) { (void)fclose(fin); return; } @@ -915,16 +915,16 @@ rcv_email(SCR *sp, const char *fname) argv[2] = fname; argv[3] = NULL; - fout = popenve(_PATH_SENDMAIL, argv, environ, "w"); + fout = popenve(_PATH_SENDMAIL, __UNCONST(argv), environ, "w"); if (fout == NULL) { msgq_str(sp, M_SYSERR, - _PATH_SENDMAIL, "071|cannot execute sendmail: %s"); + _PATH_SENDMAIL, "326|cannot execute sendmail: %s"); fclose(fin); return; } - while ((x = fread(fin, 1, sizeof(buf), buf)) != 0) - (void)fwrite(fout, 1, x, buf); + while ((l = fread(buf, 1, sizeof(buf), fin)) != 0) + (void)fwrite(buf, 1, l, fout); (void)fclose(fin); (void)pclose(fout);
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Sat Nov 4 06:12:26 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: recover.c Log Message: Deal safely with recovery mail files. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/nvi/dist/common/recover.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/recover.c diff -u src/external/bsd/nvi/dist/common/recover.c:1.6 src/external/bsd/nvi/dist/common/recover.c:1.7 --- src/external/bsd/nvi/dist/common/recover.c:1.6 Fri Nov 3 23:26:41 2017 +++ src/external/bsd/nvi/dist/common/recover.c Sat Nov 4 02:12:26 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: recover.c,v 1.6 2017/11/04 03:26:41 christos Exp $ */ +/* $NetBSD: recover.c,v 1.7 2017/11/04 06:12:26 christos Exp $ */ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: recover.c,v 10.31 2001/11/01 15:24:44 skimo Exp (Berkeley) Date: 2001/11/01 15:24:44 "; #endif /* not lint */ #else -__RCSID("$NetBSD: recover.c,v 1.6 2017/11/04 03:26:41 christos Exp $"); +__RCSID("$NetBSD: recover.c,v 1.7 2017/11/04 06:12:26 christos Exp $"); #endif #include @@ -115,17 +115,17 @@ __RCSID("$NetBSD: recover.c,v 1.6 2017/1 #define VI_FHEADER "X-vi-recover-file: " #define VI_PHEADER "X-vi-recover-path: " -static int rcv_copy __P((SCR *, int, char *)); -static void rcv_email __P((SCR *, char *)); -static char *rcv_gets __P((char *, size_t, int)); -static int rcv_mailfile __P((SCR *, int, char *)); -static int rcv_mktemp __P((SCR *, char *, const char *, int)); +static int rcv_copy(SCR *, int, char *); +static void rcv_email(SCR *, const char *); +static char *rcv_gets(char *, size_t, int); +static int rcv_mailfile(SCR *, int, char *); +static int rcv_mktemp(SCR *, char *, const char *, int); /* * rcv_tmp -- * Build a file name that will be used as the recovery file. * - * PUBLIC: int rcv_tmp __P((SCR *, EXF *, char *)); + * PUBLIC: int rcv_tmp(SCR *, EXF *, char *); */ int rcv_tmp(SCR *sp, EXF *ep, char *name) @@ -186,7 +186,7 @@ err: msgq(sp, M_ERR, * rcv_init -- * Force the file to be snapshotted for recovery. * - * PUBLIC: int rcv_init __P((SCR *)); + * PUBLIC: int rcv_init(SCR *); */ int rcv_init(SCR *sp) @@ -248,7 +248,7 @@ err: msgq(sp, M_ERR, * sending email to the user if the file was modified * ending the file session * - * PUBLIC: int rcv_sync __P((SCR *, u_int)); + * PUBLIC: int rcv_sync(SCR *, u_int); */ int rcv_sync(SCR *sp, u_int flags) @@ -505,7 +505,7 @@ checkok(int fd) * rcv_list -- * List the files that can be recovered by this user. * - * PUBLIC: int rcv_list __P((SCR *)); + * PUBLIC: int rcv_list(SCR *); */ int rcv_list(SCR *sp) @@ -614,7 +614,7 @@ next: (void)fclose(fp); * rcv_read -- * Start a recovered file as the file to edit. * - * PUBLIC: int rcv_read __P((SCR *, FREF *)); + * PUBLIC: int rcv_read(SCR *, FREF *); */ int rcv_read(SCR *sp, FREF *frp) @@ -871,29 +871,61 @@ rcv_mktemp(SCR *sp, char *path, const ch return (fd); } +extern char **environ; + /* * rcv_email -- * Send email. */ static void -rcv_email(SCR *sp, char *fname) +rcv_email(SCR *sp, const char *fname) { struct stat sb; - char buf[MAXPATHLEN * 2 + 20]; + char buf[BUFSIZ]; + FILE *fin, *fout; + const char *argv[4]; + size_t l; - if (_PATH_SENDMAIL[0] != '/' || stat(_PATH_SENDMAIL, )) + if (_PATH_SENDMAIL[0] != '/' || stat(_PATH_SENDMAIL, ) == -1) { msgq_str(sp, M_SYSERR, _PATH_SENDMAIL, "071|not sending email: %s"); - else { - /* - * !!! - * If you need to port this to a system that doesn't have - * sendmail, the -t flag causes sendmail to read the message - * for the recipients instead of specifying them some other - * way. - */ - (void)snprintf(buf, sizeof(buf), - "%s -t < %s", _PATH_SENDMAIL, fname); - (void)system(buf); + return; + } + + /* + * !!! + * If you need to port this to a system that doesn't have + * sendmail, the -t flag causes sendmail to read the message + * for the recipients instead of specifying them some other + * way. + */ + if ((fin = fopen(fname, "refl")) == NULL) { + msgq_str(sp, M_SYSERR, + fname, "071|cannot open: %s"); + return; } + + if (!checkok(fname)) { + (void)fclose(fin); + return; + } + + argv[0] = _PATH_SENDMAIL; + argv[1] = "-t"; + argv[2] = fname; + argv[3] = NULL; + + fout = popenve(_PATH_SENDMAIL, argv, environ, "w"); + if (fout == NULL) { + msgq_str(sp, M_SYSERR, + _PATH_SENDMAIL, "071|cannot execute sendmail: %s"); + fclose(fin); + return; + } + + while ((x = fread(fin, 1, sizeof(buf), buf)) != 0) + (void)fwrite(fout, 1, x, buf); + + (void)fclose(fin); + (void)pclose(fout); }
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Sat Nov 4 06:12:26 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: recover.c Log Message: Deal safely with recovery mail files. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/nvi/dist/common/recover.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Sat Nov 4 03:26:41 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: recover.c Log Message: be more careful about opening recovery files... in particular deal with people trying to get 'vi -r' stuck using named pipes, symlink attacks, and coercing others opening recovery files they did not create. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/nvi/dist/common/recover.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Sat Nov 4 03:26:41 UTC 2017 Modified Files: src/external/bsd/nvi/dist/common: recover.c Log Message: be more careful about opening recovery files... in particular deal with people trying to get 'vi -r' stuck using named pipes, symlink attacks, and coercing others opening recovery files they did not create. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/nvi/dist/common/recover.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/recover.c diff -u src/external/bsd/nvi/dist/common/recover.c:1.5 src/external/bsd/nvi/dist/common/recover.c:1.6 --- src/external/bsd/nvi/dist/common/recover.c:1.5 Sun Jan 26 16:43:45 2014 +++ src/external/bsd/nvi/dist/common/recover.c Fri Nov 3 23:26:41 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: recover.c,v 1.5 2014/01/26 21:43:45 christos Exp $ */ +/* $NetBSD: recover.c,v 1.6 2017/11/04 03:26:41 christos Exp $ */ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -16,7 +16,7 @@ static const char sccsid[] = "Id: recover.c,v 10.31 2001/11/01 15:24:44 skimo Exp (Berkeley) Date: 2001/11/01 15:24:44 "; #endif /* not lint */ #else -__RCSID("$NetBSD: recover.c,v 1.5 2014/01/26 21:43:45 christos Exp $"); +__RCSID("$NetBSD: recover.c,v 1.6 2017/11/04 03:26:41 christos Exp $"); #endif #include @@ -482,6 +482,22 @@ err: if (!issync) } /* + * Since vi creates recovery files only accessible by the user, files + * accessible by group or others are probably malicious so avoid them. + * This is simpler than checking for getuid() == st.st_uid and we want + * to preserve the functionality that root can recover anything which + * means that root should know better and be careful. + */ +static int +checkok(int fd) +{ + struct stat sb; + + return fstat(fd, ) != -1 && S_ISREG(sb.st_mode) && + (sb.st_mode & (S_IRWXG|S_IRWXO)) == 0; +} + +/* * people making love * never exactly the same * just like a snowflake @@ -525,9 +541,14 @@ rcv_list(SCR *sp) * if we're using fcntl(2), there's no way to lock a file * descriptor that's not open for writing. */ - if ((fp = fopen(dp->d_name, "r+")) == NULL) + if ((fp = fopen(dp->d_name, "r+efl")) == NULL) continue; + if (!checkok(fileno(fp))) { + (void)fclose(fp); + continue; + } + switch (file_lock(sp, NULL, NULL, fileno(fp), 1)) { case LOCK_FAILED: /* @@ -638,9 +659,15 @@ rcv_read(SCR *sp, FREF *frp) * if we're using fcntl(2), there's no way to lock a file * descriptor that's not open for writing. */ - if ((fd = open(recpath, O_RDWR, 0)) == -1) + if ((fd = open(recpath, O_RDWR|O_NONBLOCK|O_NOFOLLOW|O_CLOEXEC, + 0)) == -1) continue; + if (!checkok(fd)) { + (void)close(fd); + continue; + } + switch (file_lock(sp, NULL, NULL, fd, 1)) { case LOCK_FAILED: /*
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Thu Jan 7 14:07:01 UTC 2016 Modified Files: src/external/bsd/nvi/dist/common: key.h Log Message: remove CONST; it is unused from Brad Harder To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/nvi/dist/common/key.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Tue Jan 7 21:46:47 UTC 2014 Modified Files: src/external/bsd/nvi/dist/common: conv.c Log Message: handle unaligned accesses To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/nvi/dist/common/conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/conv.c diff -u src/external/bsd/nvi/dist/common/conv.c:1.2 src/external/bsd/nvi/dist/common/conv.c:1.3 --- src/external/bsd/nvi/dist/common/conv.c:1.2 Fri Nov 22 10:52:05 2013 +++ src/external/bsd/nvi/dist/common/conv.c Tue Jan 7 16:46:47 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: conv.c,v 1.2 2013/11/22 15:52:05 christos Exp $ */ +/* $NetBSD: conv.c,v 1.3 2014/01/07 21:46:47 christos Exp $ */ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -53,8 +53,10 @@ raw2int(SCR *sp, const char * str, ssize BINC_RETW(NULL, *tostr, *blen, len); *tolen = len; -for (i = 0; i len; ++i) - (*tostr)[i] = (u_char) str[i]; +for (i = 0; i len; ++i) { + CHAR_T w = (u_char)str[i]; + memcpy((*tostr) + i, w, sizeof(**tostr)); +} *dst = cw-bp1; @@ -131,11 +133,15 @@ default_char2int(SCR *sp, const char * s #endif for (i = 0, j = 0; j len; ) { - n = mbrtowc((*tostr)+i, src+j, len-j, mbs); + CHAR_T w; + n = mbrtowc(w, src + j, len - j, mbs); + memcpy((*tostr) + i, w, sizeof(**tostr)); /* NULL character converted */ - if (n == (size_t)-2) error = -(len-j); - if (n == (size_t)-1 || n == (size_t)-2) - HANDLE_MBR_ERROR(n, mbs, (*tostr)[i], src[j]); + if (n == (size_t)-2) error = -(len - j); + if (n == (size_t)-1 || n == (size_t)-2) { + HANDLE_MBR_ERROR(n, mbs, w, src[j]); + memcpy((*tostr) + i, w, sizeof(**tostr)); + } if (n == 0) n = 1; j += n; if (++i = *blen) { @@ -216,8 +222,11 @@ int2raw(SCR *sp, const CHAR_T * str, ssi BINC_RETC(NULL, *tostr, *blen, len); *tolen = len; -for (i = 0; i len; ++i) - (*tostr)[i] = str[i]; +for (i = 0; i len; ++i) { + CHAR_T w; + memcpy(w, str + i, sizeof(w)); + (*tostr)[i] = w; +} *dst = cw-bp1; @@ -282,9 +291,11 @@ default_int2char(SCR *sp, const CHAR_T * #endif for (i = 0, j = 0; i (size_t)len; ++i) { - n = wcrtomb(dst+j, str[i], mbs); + CHAR_T w; + memcpy(w, str + i, sizeof(w)); + n = wcrtomb(dst + j, w, mbs); if (n == (size_t)-1) - HANDLE_MBR_ERROR(n, mbs, dst[j], str[i]); + HANDLE_MBR_ERROR(n, mbs, dst[j], w); j += n; if (buflen j + MB_CUR_MAX) { if (id != (iconv_t)-1) { @@ -297,7 +308,7 @@ default_int2char(SCR *sp, const CHAR_T * } } -n = wcrtomb(dst+j, L'\0', mbs); +n = wcrtomb(dst + j, L'\0', mbs); j += n - 1;/* don't count NUL at the end */ *tolen = j;
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Tue Jan 7 21:46:47 UTC 2014 Modified Files: src/external/bsd/nvi/dist/common: conv.c Log Message: handle unaligned accesses To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/nvi/dist/common/conv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: joerg Date: Tue Jan 7 02:14:02 UTC 2014 Modified Files: src/external/bsd/nvi/dist/common: common.h Log Message: Check format strings for ex_printf. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/nvi/dist/common/common.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/common.h diff -u src/external/bsd/nvi/dist/common/common.h:1.2 src/external/bsd/nvi/dist/common/common.h:1.3 --- src/external/bsd/nvi/dist/common/common.h:1.2 Fri Nov 22 15:52:05 2013 +++ src/external/bsd/nvi/dist/common/common.h Tue Jan 7 02:14:02 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: common.h,v 1.2 2013/11/22 15:52:05 christos Exp $ */ +/* $NetBSD: common.h,v 1.3 2014/01/07 02:14:02 joerg Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -57,6 +57,8 @@ typedef struct _tagq TAGQ; typedef struct _text TEXT; typedef struct _win WIN; +int ex_printf(SCR *, const char *, ...) __printflike(2, 3); + /* Autoindent state. */ typedef enum { C_NOTSET, C_CARATSET, C_ZEROSET } carat_t;
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: joerg Date: Tue Jan 7 02:14:02 UTC 2014 Modified Files: src/external/bsd/nvi/dist/common: common.h Log Message: Check format strings for ex_printf. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/nvi/dist/common/common.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: mlelstv Date: Mon Jan 6 07:56:47 UTC 2014 Modified Files: src/external/bsd/nvi/dist/common: screen.c Log Message: screen_end can be called multiple times for the same screen. Work around segfault in TAILQ_REMOVE by abusing the tqe_prev pointer as a flag that identifies an already removed node. This should really be solved by calling screen_end only once or by keeping state explicitely in the screen structure. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/nvi/dist/common/screen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/screen.c diff -u src/external/bsd/nvi/dist/common/screen.c:1.6 src/external/bsd/nvi/dist/common/screen.c:1.7 --- src/external/bsd/nvi/dist/common/screen.c:1.6 Sun Dec 1 21:48:33 2013 +++ src/external/bsd/nvi/dist/common/screen.c Mon Jan 6 07:56:47 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: screen.c,v 1.6 2013/12/01 21:48:33 christos Exp $ */ +/* $NetBSD: screen.c,v 1.7 2014/01/06 07:56:47 mlelstv Exp $ */ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -139,9 +139,14 @@ screen_end1(SCR *sp, int init) * * If a created screen failed during initialization, it may not * be linked into the chain. + * + * XXX screen_end can be called multiple times, abuse the tqe_prev pointer + * to signal wether the tailq node is on-list. */ - if (init) + if (init sp-q.tqe_prev) { TAILQ_REMOVE(sp-wp-scrq, sp, q); + sp-q.tqe_prev = NULL; + } /* The screen is no longer real. */ F_CLR(sp, SC_SCR_EX | SC_SCR_VI);
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: mlelstv Date: Mon Jan 6 07:56:47 UTC 2014 Modified Files: src/external/bsd/nvi/dist/common: screen.c Log Message: screen_end can be called multiple times for the same screen. Work around segfault in TAILQ_REMOVE by abusing the tqe_prev pointer as a flag that identifies an already removed node. This should really be solved by calling screen_end only once or by keeping state explicitely in the screen structure. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/nvi/dist/common/screen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Sat Nov 30 14:54:29 UTC 2013 Modified Files: src/external/bsd/nvi/dist/common: recover.c vi_db1.c Log Message: Fix recovery mode, there were multiple issues: 1. the btree filename was not set so that we always used a transient in-memory db for the data 2. we did not call sync after creation with R_RECNOSYNC so that the header of the btree was never written 3. we did not call the right flavor of sync before copying the tree to the preserved files To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/recover.c cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/vi_db1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/recover.c diff -u src/external/bsd/nvi/dist/common/recover.c:1.3 src/external/bsd/nvi/dist/common/recover.c:1.4 --- src/external/bsd/nvi/dist/common/recover.c:1.3 Wed Nov 27 16:17:36 2013 +++ src/external/bsd/nvi/dist/common/recover.c Sat Nov 30 09:54:29 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: recover.c,v 1.3 2013/11/27 21:17:36 christos Exp $ */ +/* $NetBSD: recover.c,v 1.4 2013/11/30 14:54:29 christos Exp $ */ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -260,7 +260,15 @@ rcv_sync(SCR *sp, u_int flags) /* Sync the file if it's been modified. */ if (F_ISSET(ep, F_MODIFIED)) { - if (ep-db-sync(ep-db, 0)) { + /* + * If we are using a db1 version of the database, + * we want to sync the underlying btree not the + * recno tree which is transient anyway. + */ +#ifndef R_RECNOSYNC +#define R_RECNOSYNC 0 +#endif + if (ep-db-sync(ep-db, R_RECNOSYNC)) { F_CLR(ep, F_RCV_ON | F_RCV_NORM); msgq_str(sp, M_SYSERR, ep-rcv_path, 060|File backup failed: %s); Index: src/external/bsd/nvi/dist/common/vi_db1.c diff -u src/external/bsd/nvi/dist/common/vi_db1.c:1.4 src/external/bsd/nvi/dist/common/vi_db1.c:1.5 --- src/external/bsd/nvi/dist/common/vi_db1.c:1.4 Fri Nov 29 16:57:31 2013 +++ src/external/bsd/nvi/dist/common/vi_db1.c Sat Nov 30 09:54:29 2013 @@ -685,10 +685,19 @@ db_init(SCR *sp, EXF *ep, char *rcv_name memset(oinfo, 0, sizeof(RECNOINFO)); oinfo.bval = '\n'; /* Always set. */ - oinfo.psize = psize; - oinfo.flags = R_SNAPSHOT; - if (rcv_name) - oinfo.bfname = ep-rcv_path; + /* + * If we are not recovering, set the pagesize and arrange to + * first get a snapshot of the file. + */ + if (rcv_name == NULL) { + oinfo.psize = psize; + oinfo.flags = R_SNAPSHOT; + } + /* + * Always set the btree name, otherwise we are going to be using + * an in-memory database for the btree. + */ + oinfo.bfname = ep-rcv_path; #define _DB_OPEN_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH @@ -709,6 +718,12 @@ db_init(SCR *sp, EXF *ep, char *rcv_name *open_err = 1; return 1; + } else { + /* + * We always sync the underlying btree so that the header + * is written first + */ + ep-db-sync(ep-db, R_RECNOSYNC); } return 0;
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Sun Dec 1 02:21:58 UTC 2013 Modified Files: src/external/bsd/nvi/dist/common: vi_db1.c Log Message: fix indentantion To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/nvi/dist/common/vi_db1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/vi_db1.c diff -u src/external/bsd/nvi/dist/common/vi_db1.c:1.5 src/external/bsd/nvi/dist/common/vi_db1.c:1.6 --- src/external/bsd/nvi/dist/common/vi_db1.c:1.5 Sat Nov 30 09:54:29 2013 +++ src/external/bsd/nvi/dist/common/vi_db1.c Sat Nov 30 21:21:58 2013 @@ -123,27 +123,27 @@ db_get(SCR *sp, db_recno_t lno, u_int32_ #if defined(DBDEBUG) defined(TRACE) vtrace( retrieve TEXT buffer line %lu\n, (u_long)lno); -#endif - for (tp = TAILQ_FIRST(sp-tiq); -tp-lno != lno; tp = TAILQ_NEXT(tp, q)); - if (lenp != NULL) -*lenp = tp-len; - if (pp != NULL) -*pp = tp-lb; - return (0); - } - /* - * Adjust the line number for the number of lines used - * by the text input buffers. - */ - if (lno l2) - lno -= l2 - l1; - } +#endif + for (tp = TAILQ_FIRST(sp-tiq); + tp-lno != lno; tp = TAILQ_NEXT(tp, q)); + if (lenp != NULL) +*lenp = tp-len; + if (pp != NULL) +*pp = tp-lb; + return (0); + } + /* + * Adjust the line number for the number of lines used + * by the text input buffers. + */ + if (lno l2) + lno -= l2 - l1; + } - /* Look-aside into the cache, and see if the line we want is there. */ - if (lno == sp-c_lno) { -#if defined(DBDEBUG) defined(TRACE) - vtrace(retrieve cached line %lu\n, (u_long)lno); + /* Look-aside into the cache, and see if the line we want is there. */ + if (lno == sp-c_lno) { +#if defined(DBDEBUG) defined(TRACE) + vtrace(retrieve cached line %lu\n, (u_long)lno); #endif if (lenp != NULL) *lenp = sp-c_len;
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Sat Nov 30 14:54:29 UTC 2013 Modified Files: src/external/bsd/nvi/dist/common: recover.c vi_db1.c Log Message: Fix recovery mode, there were multiple issues: 1. the btree filename was not set so that we always used a transient in-memory db for the data 2. we did not call sync after creation with R_RECNOSYNC so that the header of the btree was never written 3. we did not call the right flavor of sync before copying the tree to the preserved files To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/recover.c cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/vi_db1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Sun Dec 1 02:21:58 UTC 2013 Modified Files: src/external/bsd/nvi/dist/common: vi_db1.c Log Message: fix indentantion To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/nvi/dist/common/vi_db1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Fri Nov 29 16:36:11 UTC 2013 Modified Files: src/external/bsd/nvi/dist/common: log1.c trace.c Log Message: fix compilation of log debugging To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/nvi/dist/common/log1.c \ src/external/bsd/nvi/dist/common/trace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/log1.c diff -u src/external/bsd/nvi/dist/common/log1.c:1.2 src/external/bsd/nvi/dist/common/log1.c:1.3 --- src/external/bsd/nvi/dist/common/log1.c:1.2 Fri Nov 22 10:52:05 2013 +++ src/external/bsd/nvi/dist/common/log1.c Fri Nov 29 11:36:11 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: log1.c,v 1.2 2013/11/22 15:52:05 christos Exp $ */ +/* $NetBSD: log1.c,v 1.3 2013/11/29 16:36:11 christos Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -66,8 +66,8 @@ static const char sccsid[] = Id: log.c, static int log_cursor1 __P((SCR *, int)); static void log_err __P((SCR *, const char *, int)); -#if defined(DEBUG) 0 -static void log_trace __P((SCR *, char *, db_recno_t, u_char *)); +#if defined(LOGDEBUG) defined(TRACE) +static void log_trace __P((SCR *, const char *, db_recno_t, u_char *)); #endif /* Try and restart the log on failure, i.e. if we run out of memory. */ @@ -214,8 +214,8 @@ log_cursor1(SCR *sp, int type) if (ep-log-put(ep-log, key, data, 0) == -1) LOG_ERR; -#if defined(DEBUG) 0 - vtrace(sp, %lu: %s: %u/%u\n, ep-l_cur, +#if defined(LOGDEBUG) defined(TRACE) + vtrace(%lu: %s: %u/%u\n, ep-l_cur, type == LOG_CURSOR_INIT ? log_cursor_init : log_cursor_end, sp-lno, sp-cno); #endif @@ -310,30 +310,30 @@ log_line(SCR *sp, db_recno_t lno, u_int if (ep-log-put(ep-log, key, data, 0) == -1) LOG_ERR; -#if defined(DEBUG) 0 +#if defined(LOGDEBUG) defined(TRACE) switch (action) { case LOG_LINE_APPEND_F: - vtrace(sp, %u: log_line: append_f: %lu {%u}\n, + vtrace(%u: log_line: append_f: %lu {%u}\n, ep-l_cur, lno, len); break; case LOG_LINE_APPEND_B: - vtrace(sp, %u: log_line: append_b: %lu {%u}\n, + vtrace(%u: log_line: append_b: %lu {%u}\n, ep-l_cur, lno, len); break; case LOG_LINE_DELETE_F: - vtrace(sp, %lu: log_line: delete_f: %lu {%u}\n, + vtrace(%lu: log_line: delete_f: %lu {%u}\n, ep-l_cur, lno, len); break; case LOG_LINE_DELETE_B: - vtrace(sp, %lu: log_line: delete_b: %lu {%u}\n, + vtrace(%lu: log_line: delete_b: %lu {%u}\n, ep-l_cur, lno, len); break; case LOG_LINE_RESET_F: - vtrace(sp, %lu: log_line: reset_f: %lu {%u}\n, + vtrace(%lu: log_line: reset_f: %lu {%u}\n, ep-l_cur, lno, len); break; case LOG_LINE_RESET_B: - vtrace(sp, %lu: log_line: reset_b: %lu {%u}\n, + vtrace(%lu: log_line: reset_b: %lu {%u}\n, ep-l_cur, lno, len); break; } @@ -385,8 +385,8 @@ log_mark(SCR *sp, LMARK *lmp) if (ep-log-put(ep-log, key, data, 0) == -1) LOG_ERR; -#if defined(DEBUG) 0 - vtrace(sp, %lu: mark %c: %lu/%u\n, +#if defined(LOGDEBUG) defined(TRACE) + vtrace(%lu: mark %c: %lu/%u\n, ep-l_cur, lmp-name, lmp-lno, lmp-cno); #endif /* Reset high water mark. */ @@ -438,7 +438,7 @@ log_backward(SCR *sp, MARK *rp) --ep-l_cur; if (ep-log-get(ep-log, key, data, 0)) LOG_ERR; -#if defined(DEBUG) 0 +#if defined(LOGDEBUG) defined(TRACE) log_trace(sp, log_backward, ep-l_cur, data.data); #endif switch (*(p = (u_char *)data.data)) { @@ -547,7 +547,7 @@ log_setline(SCR *sp) --ep-l_cur; if (ep-log-get(ep-log, key, data, 0)) LOG_ERR; -#if defined(DEBUG) 0 +#if defined(LOGDEBUG) defined(TRACE) log_trace(sp, log_setline, ep-l_cur, data.data); #endif switch (*(p = (u_char *)data.data)) { @@ -642,7 +642,7 @@ log_forward(SCR *sp, MARK *rp) ++ep-l_cur; if (ep-log-get(ep-log, key, data, 0)) LOG_ERR; -#if defined(DEBUG) 0 +#if defined(LOGDEBUG) defined(TRACE) log_trace(sp, log_forward, ep-l_cur, data.data); #endif switch (*(p = (u_char *)data.data)) { @@ -721,11 +721,11 @@ log_err(SCR *sp, const char *file, int l msgq(sp, M_ERR, 267|Log restarted); } -#if defined(DEBUG) 0 +#if defined(LOGDEBUG) defined(TRACE) static void log_trace(sp, msg, rno, p) SCR *sp; - char *msg; + const char *msg; db_recno_t rno; u_char *p; { @@ -736,40 +736,39 @@ log_trace(sp, msg, rno, p) switch (*p) { case LOG_CURSOR_INIT: memmove(m, p + sizeof(u_char), sizeof(MARK)); - vtrace(sp, %lu: %s: C_INIT: %u/%u\n, rno, msg, m.lno, m.cno); + vtrace(%lu: %s: C_INIT: %u/%u\n, rno, msg, m.lno, m.cno); break; case LOG_CURSOR_END: memmove(m, p + sizeof(u_char), sizeof(MARK)); - vtrace(sp, %lu: %s: C_END: %u/%u\n, rno, msg, m.lno, m.cno); + vtrace(%lu: %s: C_END: %u/%u\n, rno, msg, m.lno, m.cno); break; case LOG_LINE_APPEND_F: memmove(lno, p + sizeof(u_char),
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Fri Nov 29 21:57:31 UTC 2013 Modified Files: src/external/bsd/nvi/dist/common: vi_db1.c Log Message: make the debugging code work again. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/vi_db1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/vi_db1.c diff -u src/external/bsd/nvi/dist/common/vi_db1.c:1.3 src/external/bsd/nvi/dist/common/vi_db1.c:1.4 --- src/external/bsd/nvi/dist/common/vi_db1.c:1.3 Mon Nov 25 17:43:46 2013 +++ src/external/bsd/nvi/dist/common/vi_db1.c Fri Nov 29 16:57:31 2013 @@ -120,30 +120,30 @@ db_get(SCR *sp, db_recno_t lno, u_int32_ l1 = TAILQ_FIRST(sp-tiq)-lno; l2 = TAILQ_LAST(sp-tiq, _texth)-lno; if (l1 = lno l2 = lno) { -#if defined(DEBUG) 0 - vtrace(sp, +#if defined(DBDEBUG) defined(TRACE) + vtrace( retrieve TEXT buffer line %lu\n, (u_long)lno); -#endif - for (tp = TAILQ_FIRST(sp-tiq); - tp-lno != lno; tp = TAILQ_NEXT(tp, q)); - if (lenp != NULL) -*lenp = tp-len; - if (pp != NULL) -*pp = tp-lb; - return (0); - } - /* - * Adjust the line number for the number of lines used - * by the text input buffers. - */ - if (lno l2) - lno -= l2 - l1; - } +#endif + for (tp = TAILQ_FIRST(sp-tiq); +tp-lno != lno; tp = TAILQ_NEXT(tp, q)); + if (lenp != NULL) +*lenp = tp-len; + if (pp != NULL) +*pp = tp-lb; + return (0); + } + /* + * Adjust the line number for the number of lines used + * by the text input buffers. + */ + if (lno l2) + lno -= l2 - l1; + } - /* Look-aside into the cache, and see if the line we want is there. */ - if (lno == sp-c_lno) { -#if defined(DEBUG) 0 - vtrace(sp, retrieve cached line %lu\n, (u_long)lno); + /* Look-aside into the cache, and see if the line we want is there. */ + if (lno == sp-c_lno) { +#if defined(DBDEBUG) defined(TRACE) + vtrace(retrieve cached line %lu\n, (u_long)lno); #endif if (lenp != NULL) *lenp = sp-c_len; @@ -198,8 +198,8 @@ err3: if (lenp != NULL) sp-c_lno = lno; sp-c_len = wlen; -#if defined(DEBUG) 0 - vtrace(sp, retrieve DB line %lu\n, (u_long)lno); +#if defined(DBDEBUG) defined(TRACE) + vtrace(retrieve DB line %lu\n, (u_long)lno); #endif if (lenp != NULL) *lenp = wlen; @@ -220,8 +220,8 @@ db_delete(SCR *sp, db_recno_t lno) DBT key; EXF *ep; -#if defined(DEBUG) 0 - vtrace(sp, delete line %lu\n, (u_long)lno); +#if defined(DBDEBUG) defined(TRACE) + vtrace(delete line %lu\n, (u_long)lno); #endif /* Check for no underlying file. */ if ((ep = sp-ep) == NULL) { @@ -285,8 +285,8 @@ db_append(SCR *sp, int update, db_recno_ size_t flen; int rval; -#if defined(DEBUG) 0 - vtrace(sp, append to %lu: len %u {%.*s}\n, lno, len, MIN(len, 20), p); +#if defined(DBDEBUG) defined(TRACE) + vtrace(append to %lu: len %u {%.*s}\n, lno, len, MIN(len, 20), p); #endif /* Check for no underlying file. */ if ((ep = sp-ep) == NULL) { @@ -360,8 +360,8 @@ db_insert(SCR *sp, db_recno_t lno, CHAR_ size_t flen; int rval; -#if defined(DEBUG) 0 - vtrace(sp, insert before %lu: len %lu {%.*s}\n, +#if defined(DBDEBUG) defined(TRACE) + vtrace(insert before %lu: len %lu {%.*s}\n, (u_long)lno, (u_long)len, MIN(len, 20), p); #endif /* Check for no underlying file. */ @@ -426,8 +426,8 @@ db_set(SCR *sp, db_recno_t lno, CHAR_T * const char *fp; size_t flen; -#if defined(DEBUG) 0 - vtrace(sp, replace line %lu: len %lu {%.*s}\n, +#if defined(DBDEBUG) defined(TRACE) + vtrace(replace line %lu: len %lu {%.*s}\n, (u_long)lno, (u_long)len, MIN(len, 20), p); #endif /* Check for no underlying file. */
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Fri Nov 29 16:36:11 UTC 2013 Modified Files: src/external/bsd/nvi/dist/common: log1.c trace.c Log Message: fix compilation of log debugging To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/nvi/dist/common/log1.c \ src/external/bsd/nvi/dist/common/trace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Fri Nov 29 21:57:31 UTC 2013 Modified Files: src/external/bsd/nvi/dist/common: vi_db1.c Log Message: make the debugging code work again. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/vi_db1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Wed Nov 27 18:11:50 UTC 2013 Modified Files: src/external/bsd/nvi/dist/common: exf.c Log Message: CID 1132768 Clarify assign To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/exf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/exf.c diff -u src/external/bsd/nvi/dist/common/exf.c:1.3 src/external/bsd/nvi/dist/common/exf.c:1.4 --- src/external/bsd/nvi/dist/common/exf.c:1.3 Mon Nov 25 17:43:46 2013 +++ src/external/bsd/nvi/dist/common/exf.c Wed Nov 27 13:11:50 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: exf.c,v 1.3 2013/11/25 22:43:46 christos Exp $ */ +/* $NetBSD: exf.c,v 1.4 2013/11/27 18:11:50 christos Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -711,7 +711,7 @@ file_end(SCR *sp, EXF *ep, int force) db_env_close(ep-env, 0); ep-env = 0; - if ((sp-db_error = db_env_create(env, 0))) + if ((sp-db_error = db_env_create(env, 0)) != NULL) msgq(sp, M_DBERR, env_create); if ((sp-db_error = db_env_remove(env, ep-env_path, 0))) msgq(sp, M_DBERR, env-remove);
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: tron Date: Wed Nov 27 20:31:01 UTC 2013 Modified Files: src/external/bsd/nvi/dist/common: exf.c Log Message: Fix compiler error caused by last change: db_env_create() returns an integer. So we must not compare its return value with NULL. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/exf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/exf.c diff -u src/external/bsd/nvi/dist/common/exf.c:1.4 src/external/bsd/nvi/dist/common/exf.c:1.5 --- src/external/bsd/nvi/dist/common/exf.c:1.4 Wed Nov 27 18:11:50 2013 +++ src/external/bsd/nvi/dist/common/exf.c Wed Nov 27 20:31:01 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: exf.c,v 1.4 2013/11/27 18:11:50 christos Exp $ */ +/* $NetBSD: exf.c,v 1.5 2013/11/27 20:31:01 tron Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -711,9 +711,9 @@ file_end(SCR *sp, EXF *ep, int force) db_env_close(ep-env, 0); ep-env = 0; - if ((sp-db_error = db_env_create(env, 0)) != NULL) + if ((sp-db_error = db_env_create(env, 0)) != 0) msgq(sp, M_DBERR, env_create); - if ((sp-db_error = db_env_remove(env, ep-env_path, 0))) + if ((sp-db_error = db_env_remove(env, ep-env_path, 0)) != 0) msgq(sp, M_DBERR, env-remove); if (ep-env_path != NULL rmdir(ep-env_path)) msgq_str(sp, M_SYSERR, ep-env_path, 242|%s: remove);
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Wed Nov 27 21:17:36 UTC 2013 Modified Files: src/external/bsd/nvi/dist/common: recover.c Log Message: CID 272343: Fix resource leak To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/nvi/dist/common/recover.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/recover.c diff -u src/external/bsd/nvi/dist/common/recover.c:1.2 src/external/bsd/nvi/dist/common/recover.c:1.3 --- src/external/bsd/nvi/dist/common/recover.c:1.2 Fri Nov 22 10:52:05 2013 +++ src/external/bsd/nvi/dist/common/recover.c Wed Nov 27 16:17:36 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: recover.c,v 1.2 2013/11/22 15:52:05 christos Exp $ */ +/* $NetBSD: recover.c,v 1.3 2013/11/27 21:17:36 christos Exp $ */ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -760,6 +760,7 @@ next: (void)close(fd); /* We believe the file is recoverable. */ F_SET(ep, F_RCV_ON); + free(pathp); return (0); }
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Thu Nov 28 03:14:28 UTC 2013 Modified Files: src/external/bsd/nvi/dist/common: vi_db.c Log Message: fix syntax error To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/vi_db.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/nvi/dist/common/vi_db.c diff -u src/external/bsd/nvi/dist/common/vi_db.c:1.3 src/external/bsd/nvi/dist/common/vi_db.c:1.4 --- src/external/bsd/nvi/dist/common/vi_db.c:1.3 Mon Nov 25 17:43:46 2013 +++ src/external/bsd/nvi/dist/common/vi_db.c Wed Nov 27 22:14:28 2013 @@ -495,7 +495,7 @@ db_exist(SCR *sp, db_recno_t lno) if (ep-c_nlines != OOBLNO) return (lno = (F_ISSET(sp, SC_TINPUT) ? ep-c_nlines + TAILQ_LAST(sp-tiq, _texth)-lno - - TAILQ_FIRST(sp-tiq-lno) : ep-c_nlines)); + TAILQ_FIRST(sp-tiq)-lno : ep-c_nlines)); /* Go get the line. */ return (!db_get(sp, lno, 0, NULL, NULL));
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: tron Date: Wed Nov 27 20:31:01 UTC 2013 Modified Files: src/external/bsd/nvi/dist/common: exf.c Log Message: Fix compiler error caused by last change: db_env_create() returns an integer. So we must not compare its return value with NULL. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/exf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Wed Nov 27 21:17:36 UTC 2013 Modified Files: src/external/bsd/nvi/dist/common: recover.c Log Message: CID 272343: Fix resource leak To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/nvi/dist/common/recover.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/bsd/nvi/dist/common
Module Name:src Committed By: christos Date: Thu Nov 28 03:14:28 UTC 2013 Modified Files: src/external/bsd/nvi/dist/common: vi_db.c Log Message: fix syntax error To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/vi_db.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.