From 1ad9baefb6afa9445d771c319d7e1aa5276989f2 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/netproto/ncp/ncp_mod.c | 3 ++- usr.bin/gzip/zuncompress.c | 3 +-- 4 files changed, 5 insertions(+), 5 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/netproto/ncp/ncp_mod.c b/sys/netproto/ncp/ncp_mod.c index 22c99baef9..1b91a82c35 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