From 277dbd163cd03cd859e806c527a9964c2db1d2b3 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Thu, 21 Jun 2012 04:25:19 +0200 Subject: [PATCH] Fix more wrong sizeof() usages, part 3/x Some comments: * The gzip fix speeds up uncompression of compress(1)'d files with gzip. A test here took 9s with the fix when it previously took 15s. * Our OpenSSH is without J-PAKE support, hence the OpenSSH fix is only cosmetical. Found-with: Coccinelle (http://coccinelle.lip6.fr/) --- crypto/openssh/jpake.c | 2 +- sys/dev/acpica5/acpi_package.c | 2 +- sys/dev/raid/mfi/mfi_tbolt.c | 2 +- sys/netinet/ip_carp.c | 4 ++-- sys/netproto/ncp/ncp_mod.c | 3 ++- usr.bin/gzip/zuncompress.c | 3 +-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crypto/openssh/jpake.c b/crypto/openssh/jpake.c index ac9a4bc34a..c5a7da41d1 100644 --- a/crypto/openssh/jpake.c +++ b/crypto/openssh/jpake.c @@ -133,7 +133,7 @@ jpake_free(struct jpake_ctx *pctx) #undef JPAKE_BN_CLEAR_FREE #undef JPAKE_BUF_CLEAR_FREE - bzero(pctx, sizeof(pctx)); + bzero(pctx, sizeof(*pctx)); xfree(pctx); } diff --git a/sys/dev/acpica5/acpi_package.c b/sys/dev/acpica5/acpi_package.c index 31e3e2277a..e8a367ea5c 100644 --- a/sys/dev/acpica5/acpi_package.c +++ b/sys/dev/acpica5/acpi_package.c @@ -76,7 +76,7 @@ acpi_PkgStr(ACPI_OBJECT *res, int idx, void *dst, size_t size) obj = &res->Package.Elements[idx]; if (obj == NULL) return (EINVAL); - bzero(dst, sizeof(dst)); + bzero(dst, size); switch (obj->Type) { case ACPI_TYPE_STRING: diff --git a/sys/dev/raid/mfi/mfi_tbolt.c b/sys/dev/raid/mfi/mfi_tbolt.c index b1e317bd15..3e7ac61736 100644 --- a/sys/dev/raid/mfi/mfi_tbolt.c +++ b/sys/dev/raid/mfi/mfi_tbolt.c @@ -1130,7 +1130,7 @@ mfi_tbolt_build_mpt_cmd(struct mfi_softc *sc, struct mfi_command *cmd) if (!req_desc) return NULL; - bzero(req_desc, sizeof(req_desc)); + bzero(req_desc, sizeof(*req_desc)); req_desc->header.RequestFlags = (MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO << MFI_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); req_desc->header.SMID = index; diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 0b1159c7ea..46a60fde2a 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -2525,9 +2525,9 @@ carp_ioctl_getdevname_dispatch(netmsg_t msg) struct carp_softc *sc = cmsg->nc_softc; char *devname = cmsg->nc_data; - bzero(devname, sizeof(devname)); + bzero(devname, IFNAMSIZ); if (sc->sc_carpdev != NULL) - strlcpy(devname, sc->sc_carpdev->if_xname, sizeof(devname)); + strlcpy(devname, sc->sc_carpdev->if_xname, IFNAMSIZ); lwkt_replymsg(&cmsg->base.lmsg, 0); } diff --git a/sys/netproto/ncp/ncp_mod.c b/sys/netproto/ncp/ncp_mod.c index a1351b37c1..bfb4c6738f 100644 --- a/sys/netproto/ncp/ncp_mod.c +++ b/sys/netproto/ncp/ncp_mod.c @@ -100,7 +100,8 @@ sys_sncp_connect(struct sncp_connect_args *uap) if (!error) { error = ncp_conn_gethandle(conn, td, &handle); if (error == 0) - copyout(&handle->nh_id, uap->connHandle, sizeof(uap->connHandle)); + copyout(&handle->nh_id, uap->connHandle, + sizeof(*uap->connHandle)); ncp_conn_unlock(conn,td); } rel_mplock(); diff --git a/usr.bin/gzip/zuncompress.c b/usr.bin/gzip/zuncompress.c index 34bc8b2f7a..db5d86630b 100644 --- a/usr.bin/gzip/zuncompress.c +++ b/usr.bin/gzip/zuncompress.c @@ -1,5 +1,4 @@ /* $NetBSD: zuncompress.c,v 1.11 2011/08/16 13:55:02 joerg Exp $ */ -/* $DragonFly: src/usr.bin/gzip/zuncompress.c,v 1.1 2004/10/26 11:19:31 joerg Exp $ */ /*- * Copyright (c) 1985, 1986, 1992, 1993 @@ -146,7 +145,7 @@ zuncompress(FILE *in, FILE *out, char *pre, size_t prelen, else compressed_pre = NULL; - while ((bin = fread(buf, 1, sizeof(buf), in)) != 0) { + while ((bin = fread(buf, 1, BUFSIZE, in)) != 0) { if (tflag == 0 && (off_t)fwrite(buf, 1, bin, out) != bin) { free(buf); return -1; -- 2.41.0