From nobody Mon Mar 06 19:38:22 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PVplf440Nz3wGxw; Mon, 6 Mar 2023 19:38:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PVplf37Z0z4Mb9; Mon, 6 Mar 2023 19:38:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678131502; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pDQIMIEqmOrm7Pfib5UgVfvjR7jBj3YBZmRuBlHpzVQ=; b=BFEebBzueouc1ANnAgtE4m+7MzhKWtDMZm/TUW9CF2tsH1U6V4p1qfl/1wPBYAHvcWecjn Kvwjjng6ZnlEUWsA9+6aiFKj1c7TD8k5G/I50NqRa4tpFFc9U0m/wbzE+vnZx4yF86H9Or 5PIHljvYl6FuWXKyhdSvQwfN5Oj48dTfWMdSJvHieTaxoPW2RPWMR1SLaLLsnc0fpgm6yu E/oCCd6koD9kECCsSzma4rOCE0Ya5IRS0M1A9sNETnJT1pGRf1qF5koEAWOwExmLsmzgBY V9L8G17E7LAJjjxLbNcBbHYznMCHI+OCY8IcwNi+pDsyp6VqgdQYlVbkDsdDqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678131502; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pDQIMIEqmOrm7Pfib5UgVfvjR7jBj3YBZmRuBlHpzVQ=; b=Fn87ngAqsWS6zYnwsq0HrFK87O2p6MQNZrnoxB/HS6dsUdII0bEz5gbJHamzxtF54bZytL DjeyN8XWPTpfIfwGfJdbTgAN6+QVeeGtmV1g2s90ahWTGw5RKvNpL0HV93ICwM1PRhlHVr i5LSnZjl1M6m1pblf/M8i6F7D2wVLgwoCgEzRilmCz6iocEiG2EGtCL2CJUSJgr46zqN7/ 88xkxtrdtrUG6oJgi+XXP2O2IPy2YwxkeVScQsccumso6/2Uv0iJ+T5Eie2qLPGj9ciXQ/ zVQ62YE0ClU8CS2FYYXl5Us4z67gFIGpTKPZ95+svAvzEWBUwyiUKfjzIl/aqw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678131502; a=rsa-sha256; cv=none; b=PxiU3s+dGtnpSSFx4G08MvJmD/6u9b0FgKEvG0snN9bfEBHzv8C6sn66ZISWnKZ2/RYWe4 xdd677xKH0lP7geWFI1i3RJC2xnR/vHEZH6jRRB/zEuMUHR9wZae32frv6bry5vof5ENU8 GXbUXDeDIfzYbvZUy49H37GP4qOrNEoviyxBDWns0qd0/UhrQII2vWV/gxMYUQJCl0pYcQ lJWv1CEZr5YfZzuldvFPMUmasySLoVdaKkrCefbx/Gn+w9UTL3FQ+/2jRwv/XVll7iB60c in3Moaa2kwu1PfbyDj4QY3rJ/ECq5eAAr+Fp5U/sk3m2YP0jki6tqHdAAQ6RSA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PVplf230Bz1CyT; Mon, 6 Mar 2023 19:38:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 326JcMuL020348; Mon, 6 Mar 2023 19:38:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 326JcMjG020347; Mon, 6 Mar 2023 19:38:22 GMT (envelope-from git) Date: Mon, 6 Mar 2023 19:38:22 GMT Message-Id: <202303061938.326JcMjG020347@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: d9f07162932b - releng/13.2 - netlink: do not memcpy 0 bytes from a NULL pointer List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.2 X-Git-Reftype: branch X-Git-Commit: d9f07162932b3f34c9b1b2883773f580c0b04768 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch releng/13.2 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=d9f07162932b3f34c9b1b2883773f580c0b04768 commit d9f07162932b3f34c9b1b2883773f580c0b04768 Author: Ed Maste AuthorDate: 2023-03-06 16:30:26 +0000 Commit: Ed Maste CommitDate: 2023-03-06 19:37:56 +0000 netlink: do not memcpy 0 bytes from a NULL pointer Although it works in practice it is UB, and might break after a future compiler update. This was rewritten in main and the memcpy call no longer exists, so this is a direct commit to stable/13 before 055776c84a41 is MFC'd. Discussed with: melifaro Approved by: re (cperciva) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38927 (cherry picked from commit 305aaa93e0c805294c8bcbb5fe8b9f7caa28b349) --- sys/netlink/route/iface.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/netlink/route/iface.c b/sys/netlink/route/iface.c index 96f21a79a369..3ddef06bed7e 100644 --- a/sys/netlink/route/iface.c +++ b/sys/netlink/route/iface.c @@ -458,8 +458,11 @@ rtnl_handle_getlink(struct nlmsghdr *hdr, struct nlpcb *nlp, struct nl_pstate *n error = ENOMEM; break; } - memcpy(new_array, match_array, offset * sizeof(void *)); - free(match_array, M_TEMP); + if (match_array != NULL) { + memcpy(new_array, match_array, + offset * sizeof(void *)); + free(match_array, M_TEMP); + } match_array = new_array; }