kill alloca in favor of ssp

This commit is contained in:
christos 2017-01-07 21:11:14 +00:00
parent b223019c67
commit 863d66edc3
1 changed files with 17 additions and 23 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: swdmover.c,v 1.13 2015/08/20 14:40:17 christos Exp $ */
/* $NetBSD: swdmover.c,v 1.14 2017/01/07 21:11:14 christos Exp $ */
/*
* Copyright (c) 2002, 2003 Wasabi Systems, Inc.
@ -49,7 +49,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: swdmover.c,v 1.13 2015/08/20 14:40:17 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: swdmover.c,v 1.14 2017/01/07 21:11:14 christos Exp $");
#include <sys/param.h>
#include <sys/kthread.h>
@ -147,7 +147,7 @@ swdmover_func_zero_process(struct dmover_request *dreq)
case DMOVER_BUF_UIO:
{
struct uio *uio = dreq->dreq_outbuf.dmbuf_uio;
char *cp;
char cp[1024];
size_t count, buflen;
int error;
@ -160,9 +160,8 @@ swdmover_func_zero_process(struct dmover_request *dreq)
}
buflen = uio->uio_resid;
if (buflen > 1024)
buflen = 1024;
cp = alloca(buflen);
if (buflen > sizeof(cp))
buflen = sizeof(cp);
memset(cp, 0, buflen);
while ((count = uio->uio_resid) != 0) {
@ -209,7 +208,7 @@ swdmover_func_fill8_process(struct dmover_request *dreq)
case DMOVER_BUF_UIO:
{
struct uio *uio = dreq->dreq_outbuf.dmbuf_uio;
char *cp;
char cp[1024];
size_t count, buflen;
int error;
@ -222,9 +221,8 @@ swdmover_func_fill8_process(struct dmover_request *dreq)
}
buflen = uio->uio_resid;
if (buflen > 1024)
buflen = 1024;
cp = alloca(buflen);
if (buflen > sizeof(cp))
buflen = sizeof(cp);
memset(cp, dreq->dreq_immediate[0], buflen);
while ((count = uio->uio_resid) != 0) {
@ -334,7 +332,7 @@ swdmover_func_xor_process(struct dmover_request *dreq)
struct uio *uio_out = dreq->dreq_outbuf.dmbuf_uio;
struct uio *uio_in = dreq->dreq_inbuf[0].dmbuf_uio;
struct uio *uio;
char *cp, *dst;
char cp[1024], dst[1024];
size_t count, buflen;
int error;
@ -349,10 +347,8 @@ swdmover_func_xor_process(struct dmover_request *dreq)
}
buflen = uio_in->uio_resid;
if (buflen > 1024)
buflen = 1024;
cp = alloca(buflen);
dst = alloca(buflen);
if (buflen > sizeof(cp))
buflen = sizeof(cp);
/*
* For each block, copy first input buffer into the destination
@ -440,7 +436,7 @@ swdmover_func_copy_process(struct dmover_request *dreq)
{
struct uio *uio_out = dreq->dreq_outbuf.dmbuf_uio;
struct uio *uio_in = dreq->dreq_inbuf[0].dmbuf_uio;
char *cp;
char cp[1024];
size_t count, buflen;
int error;
@ -455,9 +451,8 @@ swdmover_func_copy_process(struct dmover_request *dreq)
}
buflen = uio_in->uio_resid;
if (buflen > 1024)
buflen = 1024;
cp = alloca(buflen);
if (buflen > sizeof(cp))
buflen = sizeof(cp);
while ((count = uio_in->uio_resid) != 0) {
if (count > buflen)
@ -595,7 +590,7 @@ swdmover_func_iscsi_crc32c_process(struct dmover_request *dreq)
case DMOVER_BUF_UIO:
{
struct uio *uio_in = dreq->dreq_inbuf[0].dmbuf_uio;
uint8_t *cp;
uint8_t cp[1024];
size_t count, buflen;
int error;
@ -608,9 +603,8 @@ swdmover_func_iscsi_crc32c_process(struct dmover_request *dreq)
}
buflen = uio_in->uio_resid;
if (buflen > 1024)
buflen = 1024;
cp = alloca(buflen);
if (buflen > sizeof(cp))
buflen = sizeof(cp);
while ((count = uio_in->uio_resid) != 0) {
if (count > buflen)