Fix more wrong sizeof() usages, part 3/x
authorSascha Wildner <saw@online.de>
Thu, 21 Jun 2012 02:25:19 +0000 (04:25 +0200)
committerSascha Wildner <saw@online.de>
Thu, 21 Jun 2012 02:26:38 +0000 (04:26 +0200)
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
sys/dev/acpica5/acpi_package.c
sys/dev/raid/mfi/mfi_tbolt.c
sys/netinet/ip_carp.c
sys/netproto/ncp/ncp_mod.c
usr.bin/gzip/zuncompress.c

index ac9a4bc..c5a7da4 100644 (file)
@@ -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);
 }
 
index 31e3e22..e8a367e 100644 (file)
@@ -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:
index b1e317b..3e7ac61 100644 (file)
@@ -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;
index 0b1159c..46a60fd 100644 (file)
@@ -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);
 }
index a1351b3..bfb4c67 100644 (file)
@@ -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();
index 34bc8b2..db5d866 100644 (file)
@@ -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;