From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E0C6F457B5; Wed, 14 Aug 2024 04:34:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ADAE2402E0; Wed, 14 Aug 2024 04:34:38 +0200 (CEST) Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by mails.dpdk.org (Postfix) with ESMTP id A99E8402A8 for ; Wed, 14 Aug 2024 04:34:37 +0200 (CEST) Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-201d6ac1426so3522765ad.1 for ; Tue, 13 Aug 2024 19:34:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1723602876; x=1724207676; darn=dpdk.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6wfdPy6nebWDGFy+zXDlgko5GrAhPI6QESmayMrOYjg=; b=wMbsKXmJvPExeqDO1zvWDtRHEeYZIXDFEnGALFPdFsK7kw9uNdelHhrVR2+R5SA5WG Tz7kctj5/opEc9ISMnpMKvxc7jIvYtJX02rpyGauAlZFaD3/T6V0LNYMcaUZ804NG1/q XnGNhzKBFgSaCeHoE3CvS2H8px3TO+9x6ZuV+eboDaPnXkA4Mm0hX1icLoDGjSShJG8u rWmCoVptZO2h7s0sKr0pMgKF3feKUF2ZpgDLgRnxgPjzfIH9GTTXwRwX9ZuSFshLI3mB Rm6tgnB3iHa7tJO9VGtT00kODCmYbRRtpeK9XJCtSSCNJ9AxIetFjp9xB8eiyTNFK32D pAbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723602876; x=1724207676; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6wfdPy6nebWDGFy+zXDlgko5GrAhPI6QESmayMrOYjg=; b=PmITsFsA2QfmNS/uZ0UQm7B241a2Ut1cm2NZYAj+as6S0HkID5lUG2CwlrPx58MB5F SCuX7MbeaIMr9eSpAjxBN+Pr5vtUCdD3QJIBnka1toBVQJVb+niIOCtJCO0IfYbJvKAj 4yecwO0dzI8zdbfqJNthfHSfS4FpX2HjujrYZNeVVnVwduEUOTrinNFvXROqCyQgdgjq mAf7wDh+I0D7MOxmLW9PVnMIBhnXS0DKySXS/rfbSUcWDwgxhUObwarM4DcLThOZXlA4 lCQqcWQWCKdMtPQ4wflA9AP+Kyb8eUI6TZsGHVS5Zv2BFPfSw9HolT+Mbf+1eMBTUevA fSQw== X-Gm-Message-State: AOJu0YwkX/f4ngrJgzcS2nprC6JtdzlbHJjGFz9+3k9539cgUA9e8cfv HfbNOXm+nrE3P2DDk4xO0qgVZ5XYfPmzzB2O4Kayl6cXtnYgNvAt9gwuXerd1Zhaj4EOrhONnFw HBxc= X-Google-Smtp-Source: AGHT+IFzgoevY78zjuv2vWnccGIEha7TJE/AxHH5wwon+6u/B2GKUXQLj6h5HbC0jgfPmz7AXKUDgQ== X-Received: by 2002:a17:902:d4c2:b0:1fa:449:1dd6 with SMTP id d9443c01a7336-201d648cd21mr16993575ad.48.1723602876475; Tue, 13 Aug 2024 19:34:36 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-201cd1314e3sm20054915ad.62.2024.08.13.19.34.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 19:34:35 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH] net/tap: avoid memcpy with NULL arg Date: Tue, 13 Aug 2024 19:34:16 -0700 Message-ID: <20240814023426.124491-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Calling memcpy with a null pointer even if zero length is undefined, so check if data_length is zero. Problem reported by Gcc analyzer. Signed-off-by: Stephen Hemminger --- drivers/net/tap/tap_netlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/tap/tap_netlink.c b/drivers/net/tap/tap_netlink.c index c7db78563a..8a57c9242c 100644 --- a/drivers/net/tap/tap_netlink.c +++ b/drivers/net/tap/tap_netlink.c @@ -302,7 +302,8 @@ tap_nlattr_add(struct nlmsghdr *nh, unsigned short type, rta = (struct rtattr *)NLMSG_TAIL(nh); rta->rta_len = RTA_LENGTH(data_len); rta->rta_type = type; - memcpy(RTA_DATA(rta), data, data_len); + if (data_len > 0) + memcpy(RTA_DATA(rta), data, data_len); nh->nlmsg_len = NLMSG_ALIGN(nh->nlmsg_len) + RTA_ALIGN(rta->rta_len); } -- 2.43.0