MFC r205938:

Sync with OpenBSD:
 - avoid coredump when there's only one token on a line;
 - Use calloc();
 - Remove a line inherited from example mdoc.

Obtained from:  OpenBSD
This commit is contained in:
delphij 2010-04-29 00:28:34 +00:00
parent a5107a3ecf
commit fcff1c0ce3
2 changed files with 5 additions and 6 deletions

View File

@ -1,5 +1,5 @@
.\" $OpenBSD: mailwrapper.8,v 1.10 2009/02/07 16:58:23 martynas Exp $
.\" $NetBSD: mailwrapper.8,v 1.11 2002/02/08 01:38:50 ross Exp $
.\" $OpenBSD: mailwrapper.8,v 1.8 2003/06/12 12:59:51 jmc Exp $
.\" $FreeBSD$
.\"
.\" Copyright (c) 1998
@ -31,7 +31,6 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" The following requests are required for all man pages.
.Dd August 7, 2006
.Dt MAILWRAPPER 8
.Os

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mailwrapper.c,v 1.16 2004/07/06 03:38:14 millert Exp $ */
/* $OpenBSD: mailwrapper.c,v 1.18 2007/11/06 14:39:19 otto Exp $ */
/* $NetBSD: mailwrapper.c,v 1.9 2003/03/09 08:10:43 mjl Exp $ */
/*
@ -61,8 +61,8 @@ initarg(struct arglist *al)
{
al->argc = 0;
al->maxc = 10;
if ((al->argv = malloc(al->maxc * sizeof(char *))) == NULL)
err(EX_TEMPFAIL, "malloc");
if ((al->argv = calloc(al->maxc, sizeof(char *))) == NULL)
err(EX_TEMPFAIL, "calloc");
}
static void
@ -126,7 +126,7 @@ main(int argc, char *argv[], char *envp[])
continue;
}
if ((from = strsep(&cp, WS)) == NULL)
if ((from = strsep(&cp, WS)) == NULL || cp == NULL)
goto parse_error;
cp += strspn(cp, WS);