Fix wrong array size calculation in call to memset() and avoid a possible
segmentation fault in memmove(). Patches supplied by Stephan Thesing in PR bin/8184.
This commit is contained in:
parent
b701be7c86
commit
c8b0d04949
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: join.c,v 1.15 1998/12/19 17:05:30 christos Exp $ */
|
||||
/* $NetBSD: join.c,v 1.16 1999/08/10 20:09:02 tron Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991 The Regents of the University of California.
|
||||
@ -48,7 +48,7 @@ __COPYRIGHT(
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)join.c 5.1 (Berkeley) 11/18/91";
|
||||
#else
|
||||
__RCSID("$NetBSD: join.c,v 1.15 1998/12/19 17:05:30 christos Exp $");
|
||||
__RCSID("$NetBSD: join.c,v 1.16 1999/08/10 20:09:02 tron Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -317,7 +317,7 @@ slurp(F)
|
||||
if ((F->set = realloc(F->set,
|
||||
F->setalloc * sizeof(LINE))) == NULL)
|
||||
enomem();
|
||||
memset(F->set + cnt, 0, 100 * sizeof(LINE *));
|
||||
memset(F->set + cnt, 0, 100 * sizeof(LINE));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -347,7 +347,7 @@ slurp(F)
|
||||
lp->linealloc * sizeof(char))) == NULL)
|
||||
enomem();
|
||||
}
|
||||
memmove(lp->line, bp, len+1);
|
||||
memmove(lp->line, bp, len);
|
||||
|
||||
/* Replace trailing newline, if it exists. */
|
||||
if (bp[len - 1] == '\n')
|
||||
|
Loading…
Reference in New Issue
Block a user