From owner-freebsd-current@FreeBSD.ORG Thu Aug 4 11:50:13 2011 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7496A1065672 for ; Thu, 4 Aug 2011 11:50:13 +0000 (UTC) (envelope-from pawel.worach@gmail.com) Received: from mail-ey0-f172.google.com (mail-ey0-f172.google.com [209.85.215.172]) by mx1.freebsd.org (Postfix) with ESMTP id 007668FC13 for ; Thu, 4 Aug 2011 11:50:12 +0000 (UTC) Received: by eye4 with SMTP id 4so814944eye.31 for ; Thu, 04 Aug 2011 04:50:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:content-type:content-transfer-encoding:subject:date:message-id :to:mime-version:x-mailer; bh=qJW171W9CHKL3urvsAIJ4VxYmTLaPOJYhH5rNVvH9iY=; b=Zk2mSwHSezvLc7/yMuL1VAeMz25rY0vpCM5EbVjbq+NXmfJMdUC1RPMMl8r4YmubCw QmUy8Oy28qFWbeqgVOekI1mh+ZigKd1cx7FsWepUcYkrXwpab0BABLZYLz6Z3pozDn6E WsNHUpxy6FSrtFYvRg9iC6puD6C3HsXaoDLGc= Received: by 10.204.140.197 with SMTP id j5mr222280bku.389.1312456851656; Thu, 04 Aug 2011 04:20:51 -0700 (PDT) Received: from [172.16.0.199] (host-78-64-61-68.homerun.telia.com [78.64.61.68]) by mx.google.com with ESMTPS id l22sm514627bku.24.2011.08.04.04.20.49 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 04 Aug 2011 04:20:50 -0700 (PDT) From: Pawel Worach Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Date: Thu, 4 Aug 2011 13:20:46 +0200 Message-Id: <3716FADF-C719-4860-9167-CFFE882A96CD@gmail.com> To: current@freebsd.org Mime-Version: 1.0 (Apple Message framework v1244.3) X-Mailer: Apple Mail (2.1244.3) Cc: Subject: Potential sizeof vs. mem*() bugs X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Aug 2011 11:50:13 -0000 Hi, clang gained a new warning for checking the sizeof argument in memset / = memcpy calls, this triggers a couple of times in the FreeBSD tree, here = is a brief summary: kerberos5/lib/libhx509/../../../crypto/heimdal/lib/hx509/cert.c:357:28: = warning: argument to 'sizeof' in 'memset' call is the same expression as = the destination; did you mean to dereference it? = [-Wsizeof-pointer-memaccess] memset(cert, 0, sizeof(cert)); ~~~~ ^~~~ -- kerberos5/lib/libhx509/../../../crypto/heimdal/lib/hx509/cert.c:357:28: = warning: argument to 'sizeof' in 'memset' call is the same expression as = the destination; did you mean to dereference it? = [-Wsizeof-pointer-memaccess] memset(cert, 0, sizeof(cert)); ~~~~ ^~~~ -- kerberos5/lib/libkrb5/../../../crypto/heimdal/lib/krb5/crypto.c:521:25: = warning: argument to 'sizeof' in 'memset' call is the same expression as = the destination; did you mean to provide an explicit length? = [-Wsizeof-pointer-memaccess] memset(x, 0, sizeof(x)); ~ ^ -- kerberos5/lib/libkrb5/../../../crypto/heimdal/lib/krb5/crypto.c:521:25: = warning: argument to 'sizeof' in 'memset' call is the same expression as = the destination; did you mean to provide an explicit length? = [-Wsizeof-pointer-memaccess] memset(x, 0, sizeof(x)); ~ ^ -- lib/libtelnet/../../contrib/telnet/libtelnet/sra.c:306:24: warning: = argument to 'sizeof' in 'memset' call is the same expression as the = destination; did you mean to provide an explicit length? = [-Wsizeof-pointer-memaccess] memset(pass,0,sizeof(pass)); ~~~~ ^~~~ -- lib/libthread_db/arch/amd64/libpthread_md.c:95:48: warning: argument to = 'sizeof' in 'memcpy' call is the same expression as the source; did you = mean to dereference it? [-Wsizeof-pointer-memaccess] memcpy(&uc->uc_mcontext.mc_fpstate, r, sizeof(r)); ~ ^ lib/libthread_db/arch/amd64/libpthread_md.c:101:48: warning: argument to = 'sizeof' in 'memcpy' call is the same expression as the destination; did = you mean to dereference it? [-Wsizeof-pointer-memaccess] memcpy(r, &uc->uc_mcontext.mc_fpstate, sizeof(r)); ~ ^ -- lib/libthread_db/arch/amd64/libpthread_md.c:95:48: warning: argument to = 'sizeof' in 'memcpy' call is the same expression as the source; did you = mean to dereference it? [-Wsizeof-pointer-memaccess] memcpy(&uc->uc_mcontext.mc_fpstate, r, sizeof(r)); ~ ^ lib/libthread_db/arch/amd64/libpthread_md.c:101:48: warning: argument to = 'sizeof' in 'memcpy' call is the same expression as the destination; did = you mean to dereference it? [-Wsizeof-pointer-memaccess] memcpy(r, &uc->uc_mcontext.mc_fpstate, sizeof(r)); ~ ^ -- ,10001:0lib/bind/isc/../../../contrib/bind9/lib/isc/hmacsha.c:228:24: = warning: argument to 'sizeof' in 'memset' call is the same expression as = the destination; did you mean to dereference it? = [-Wsizeof-pointer-memaccess] memset(ctx, 0, sizeof(ctx)); ~~~ ^~~ lib/bind/isc/../../../contrib/bind9/lib/isc/hmacsha.c:296:24: warning: = argument to 'sizeof' in 'memset' call is the same expression as the = destination; did you mean to dereference it? = [-Wsizeof-pointer-memaccess] memset(ctx, 0, sizeof(ctx)); ~~~ ^~~ lib/bind/isc/../../../contrib/bind9/lib/isc/hmacsha.c:363:24: warning: = argument to 'sizeof' in 'memset' call is the same expression as the = destination; did you mean to dereference it? = [-Wsizeof-pointer-memaccess] memset(ctx, 0, sizeof(ctx)); ~~~ ^~~ lib/bind/isc/../../../contrib/bind9/lib/isc/hmacsha.c:430:24: warning: = argument to 'sizeof' in 'memset' call is the same expression as the = destination; did you mean to dereference it? = [-Wsizeof-pointer-memaccess] memset(ctx, 0, sizeof(ctx)); ~~~ ^~~ lib/bind/isc/../../../contrib/bind9/lib/isc/hmacsha.c:497:24: warning: = argument to 'sizeof' in 'memset' call is the same expression as the = destination; did you mean to dereference it? = [-Wsizeof-pointer-memaccess] memset(ctx, 0, sizeof(ctx)); ~~~ ^~~ -- lib/bind/isc/../../../contrib/bind9/lib/isc/sha2.c:898:28: warning: = argument to 'sizeof' in 'memset' call is the same expression as the = destination; did you mean to dereference it? = [-Wsizeof-pointer-memaccess] memset(context, 0, sizeof(context)); ~~~~~~~ ^~~~~~~ lib/bind/isc/../../../contrib/bind9/lib/isc/sha2.c:1211:28: warning: = argument to 'sizeof' in 'memset' call is the same expression as the = destination; did you mean to dereference it? = [-Wsizeof-pointer-memaccess] memset(context, 0, sizeof(context)); ~~~~~~~ ^~~~~~~ lib/bind/isc/../../../contrib/bind9/lib/isc/sha2.c:1264:28: warning: = argument to 'sizeof' in 'memset' call is the same expression as the = destination; did you mean to dereference it? = [-Wsizeof-pointer-memaccess] memset(context, 0, sizeof(context)); ~~~~~~~ ^~~~~~~ lib/bind/isc/../../../contrib/bind9/lib/isc/sha2.c:1295:29: warning: = argument to 'sizeof' in 'memset' call is the same expression as the = destination; did you mean to dereference it? = [-Wsizeof-pointer-memaccess] memset(context, 0, sizeof(context)); ~~~~~~~ ^~~~~~~ lib/bind/isc/../../../contrib/bind9/lib/isc/sha2.c:1334:29: warning: = argument to 'sizeof' in 'memset' call is the same expression as the = destination; did you mean to dereference it? = [-Wsizeof-pointer-memaccess] memset(context, 0, sizeof(context)); ~~~~~~~ ^~~~~~~ lib/bind/isc/../../../contrib/bind9/lib/isc/sha2.c:1373:29: warning: = argument to 'sizeof' in 'memset' call is the same expression as the = destination; did you mean to dereference it? = [-Wsizeof-pointer-memaccess] memset(context, 0, sizeof(context)); ~~~~~~~ ^~~~~~~ lib/bind/isc/../../../contrib/bind9/lib/isc/sha2.c:1412:29: warning: = argument to 'sizeof' in 'memset' call is the same expression as the = destination; did you mean to dereference it? = [-Wsizeof-pointer-memaccess] memset(context, 0, sizeof(context)); ~~~~~~~ ^~~~~~~ -- usr.sbin/bluetooth/sdpd/server.c:76:24: warning: argument to 'sizeof' in = 'memset' call is the same expression as the destination; did you mean to = dereference it? [-Wsizeof-pointer-memaccess] memset(srv, 0, sizeof(srv)); ~~~ ^~~ -- usr.sbin/bsnmpd/bsnmpd/../../../contrib/bsnmp/snmpd/main.c:2706:36: = warning: argument to 'sizeof' in 'memset' call is the same expression as = the destination; did you mean to remove the addressof? = [-Wsizeof-pointer-memaccess] memset(&snmpd_usmstats, 0, sizeof(&snmpd_usmstats)); ~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~ -- usr.bin/csup/auth.c:257:27: warning: argument to 'sizeof' in 'memset' = call is the same expression as the destination; did you mean to provide = an explicit length? [-Wsizeof-pointer-memaccess] memset(secret, 0, sizeof(secret)); ~~~~~~ ^~~~~~ -- = /data/buildslave/freeb,10001:0sd-clang-amd64/src-freebsd/usr.bin/opiekey/.= ./../contrib/opie/opiekey.c:112:32: warning: argument to 'sizeof' in = 'memset' call is the same expression as the destination; did you mean to = provide an explicit length? [-Wsizeof-pointer-memaccess] memset(secret, 0, sizeof(secret)); ~~~~~~ ^~~~~~ usr.bin/opiekey/../../contrib/opie/opiekey.c:118:32: warning: argument = to 'sizeof' in 'memset' call is the same expression as the destination; = did you mean to provide an explicit length? [-Wsizeof-pointer-memaccess] memset(secret, 0, sizeof(secret)); ~~~~~~ ^~~~~~ usr.bin/opiekey/../../contrib/opie/opiekey.c:124:30: warning: argument = to 'sizeof' in 'memset' call is the same expression as the destination; = did you mean to provide an explicit length? [-Wsizeof-pointer-memaccess] memset(secret, 0, sizeof(secret)); ~~~~~~ ^~~~~~ -- = usr.sbin/wpa/wpa_passphrase/../../../contrib/wpa//src/crypto/md5-internal.= c:191:30: warning: argument to 'sizeof' in 'memset' call is the same = expression as the destination; did you mean to dereference it? = [-Wsizeof-pointer-memaccess] os_memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ -- usr.sbin/ypserv/yp_main.c:333:9: warning: argument to 'sizeof' in = 'memcpy' call is the same pointer type 'struct sockaddr *' as the = source; expected 'struct sockaddr' or an explicit length = [-Wsizeof-pointer-memaccess] sizeof(res->ai_addr)); ^~~~~~~~~~~~~~~~~~~~ --=20 Pawel