From patchwork Sun Dec 31 05:31:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohamed Belouarga X-Patchwork-Id: 1881316 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=ptyuZEu+; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=U/i8b7JY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::33e; helo=mail-wm1-x33e.google.com; envelope-from=swupdate+bncbcior6fiyqjbbthzyowamgqe4k43iiq@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-wm1-x33e.google.com (mail-wm1-x33e.google.com [IPv6:2a00:1450:4864:20::33e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T2nmf0Trwz1ydd for ; Sun, 31 Dec 2023 16:32:00 +1100 (AEDT) Received: by mail-wm1-x33e.google.com with SMTP id 5b1f17b1804b1-40d2fa6b23esf84352875e9.2 for ; Sat, 30 Dec 2023 21:32:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704000717; cv=pass; d=google.com; s=arc-20160816; b=Tcp5nvVDBk2ED3V72o5Rsvu3gDWye78uCj27IK2GWbGVO5jl5+l6/QQVk/KxKSu82h XpV/FvwakpZ/0K5aUbtRN/ixLR6Ae4JCvDYTSYUBksJmk5x++tKRKpHJuYBS8q9rJy2G z6x+0Vju8JzZ7kzSazWbJGZfPeS79WTqLtiZg1xrOTA9yirN17rxbzReA6HrVp9/pksf u0vbHheHpUSSzN5kEz6hZt0bH9z8WY9iuXITKjARtkWA53iqyxBMxdO5TschiUzsdfoG K70lsUCfF6XIdYPUqijQv78RqvLQDaiIo6sxprwXgYH8ZwCeeFKTVuQAIvRB4PtU6Vbd HCXw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature:dkim-signature; bh=y7SaTB9W3Bib4X1Yvv0o51MzwnhAdQjFPxbnTp0qzK4=; fh=a3VbWbiDpxqnmYDdgu1hrQI3rIX2E2gKqzRBEDNkKQU=; b=ePvBnvZbF0f0gh6cIlijR/UEpRYF+60TbfhLEr0+llVb1A9TINjN730JR/IqzlPAwJ 2NdT34gkq5utAuTNVA0ZsBc0oHUDMbcwsEpMrl0FWfLTpeGhWkH8bbsLwcvvJOa92HO0 IbJvMjkkkAryMtYAv9SECChZL6y9DzNkA9vB1BlqBmiBnmNCkGS/v8WuAOxr83cxycek KD1M6aIJJOIiYxgVU87RaeW5uNZLPou5AHziRyS+ffEBdrPGxhRRS2t+WAHRBnHm+/Db DyD7JCuIsRaduOkPt6ImB/upIOTbytnipsZlnVRmwsRaspktvvRMah4/Bawjxhl4zbhT EBwg== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=S6wGCEUQ; spf=pass (google.com: domain of belouargamohamed@gmail.com designates 2a00:1450:4864:20::430 as permitted sender) smtp.mailfrom=belouargamohamed@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1704000717; x=1704605517; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :sender:from:to:cc:subject:date:message-id:reply-to; bh=y7SaTB9W3Bib4X1Yvv0o51MzwnhAdQjFPxbnTp0qzK4=; b=ptyuZEu+F2VsYBQz7nUdsHnxyZBwGzONjEke51lJTLV9lvvFJ4P9ZTtorTdppuflZw pc5m0ef+TwuzRnkqOjU1KSsppDT29u6FHg/re7gFgJguNoNYlRJ00EqCWs6OSnMUyQhM za4JvMF4r+UEJxqsqOP02aw+lRsbxNq6dIuUgomZ2ve66UxlB1yqEx0HR4NFJ1uaq3j6 OJlQMaIOq/x8e0iY7zE3uBkVtMSfe4ZHGkUTdT/rb2EXJ8YpEKuqwCT4NP3B2xQL4Ogd 7MpYG0jdq/shpM2i1VeKLvmvdr+pFtigMjktBl1JL3Ekj1z1frO1zLwyTbxZEqlhruPR xpSQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704000717; x=1704605517; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :from:to:cc:subject:date:message-id:reply-to; bh=y7SaTB9W3Bib4X1Yvv0o51MzwnhAdQjFPxbnTp0qzK4=; b=U/i8b7JYZkGKSG81itcK+JEeYYXsZY+PTy7itEhGyEuKdvpywvDLXrmHmGWMpy58JS y9j2HWzxjUIFyENIhC27AHq1CDap35iWuT2+vKWFoZkBBPz1ZemaSggxj2Y45dDaMZYz 6mMbVQtUrFmlOkxa2PYCwHxIpIbNEwZG1aEuRuWhLH1691xWuXNOhM7FJFB4Yf3S44vD 5tN3h2N5ZsLis0eFvkD9Hd/GeRZX3G7W+DIZ1RqEFLwmOMNioJKJu0zGxZchEDu01cAt TMij+gzKxjQTe/Deiv6OAb4f/aeiJ70dMLGVwF2NQC9aAV+plYz0ZkeSQsGY3wkETlu2 YVYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704000717; x=1704605517; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:x-beenthere:x-gm-message-state :sender:from:to:cc:subject:date:message-id:reply-to; bh=y7SaTB9W3Bib4X1Yvv0o51MzwnhAdQjFPxbnTp0qzK4=; b=EqolDcT4UrCHrSVgoMuVtykNQ4ywYAi0NlavziMIjPc03LNZp7ZX0bTEGBgnWuWzMb rI0H3z24vUvCWn+I93MfSe5rIb3jBSAlDEd1gc8oemgJZ41FVuPqoYTaDZujPX6jMXs/ QrS92LQpxcsLa6S/Y4TfCQE0aV8+bu1LHoD56ZvAtw2yjebxkjaUw9xk+Ep228Zh4Z4C Omjv+08Hk5DyWTJhhaTH4SPDdB99D4Sb3GOPi6m7I/9vxaVlpPMwpbQBvQZdfzVK/v6q lIUE/FzyKqdbyF6UnqjU5eNSmf+dr67y2cU4aevKc4mt4piNjBrBIDmq2NXY+GE9yvLU gbJw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0YzPvO6J2lJ1gw2beooGhPrQKAFeOaETlFKsi6A07B12TH1PPKg4 hme6MIKQ4FUTBAhUv6vDEfk= X-Google-Smtp-Source: AGHT+IGSFUaPI+vHtj++pKelP67f9bsnkTYDEUgWfc505yqi0p2c/AcO0H5A98yU+vyZL+aUwSIlRA== X-Received: by 2002:a05:600c:a08:b0:40d:7db9:1bf4 with SMTP id z8-20020a05600c0a0800b0040d7db91bf4mr955701wmp.275.1704000716834; Sat, 30 Dec 2023 21:31:56 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:319c:b0:40d:5b7a:e307 with SMTP id s28-20020a05600c319c00b0040d5b7ae307ls1513085wmp.0.-pod-prod-02-eu; Sat, 30 Dec 2023 21:31:55 -0800 (PST) X-Received: by 2002:a05:600c:364f:b0:40d:70be:6bea with SMTP id y15-20020a05600c364f00b0040d70be6beamr1482221wmq.22.1704000714815; Sat, 30 Dec 2023 21:31:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704000714; cv=none; d=google.com; s=arc-20160816; b=jR9rlPG0f4a/CEDKL5KpUWgxeyECpFgP5yQfF5ZG7/2keiNqFNLYbXOp5TgcJM2sgk wazp+RYQby47ikyVotSQo/7nkRCOMOQ8fEY4tFVxVfne0MoJjLHHIc1AO3hOsahDjBEP rogBeFmNWr4otfAsuDG2Earvp06/kKRont/IM15kA1NnLK/LHJ55+EtqhYPrUl1tZeKU +6T69C73Iht0XyD405EwFBZAZvf4DZZNu7wDU9xA/8jAin5QlfFsrd6vP9As2GdW9HUf 8Jmx02WbuCY/LNoPc4uOzCnRMDE4TrXmOr6r+5X1D/1fStDlUTwDjOGvcrQmAweNbXza 2RWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=VEzEjd9hH9Fsj0skf4hgPw15W7K3lz5us2cSBqijp/4=; fh=a3VbWbiDpxqnmYDdgu1hrQI3rIX2E2gKqzRBEDNkKQU=; b=Emw1kX1T0r3gyPFhtGvefVs6EoCd8GlCASWQeBsNLqkaD+WVpHhe+lHLP9SRX7T6Yb AGYhdXCAD4mBngN9z1SkRU4G4MeJu5iXUAKVRVtjeymbrP2GoLWauX/KiV5mrxW4kgpE 57BY3B7zBU28H+1DTPbC4fOGTm9y01eY/4oZHRmHiIcMqVSZ1Yaez6+MWPvrTdxRysOF NCaB5AcuZ/ovGmDokIP/Y93nQszK9s9FtRYySUl4+EnrzmuSbYiicIhyHDz+MumKE0iI CDj/0BesEGEdpiwEc3YNQ3F4InBaUFge496OMpFxZhV1QFRQLlYrBsyu1Vk0IFPsQaRW Qzrg== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=S6wGCEUQ; spf=pass (google.com: domain of belouargamohamed@gmail.com designates 2a00:1450:4864:20::430 as permitted sender) smtp.mailfrom=belouargamohamed@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com. [2a00:1450:4864:20::430]) by gmr-mx.google.com with ESMTPS id gi34-20020a1709070ca200b00a2355945814si635996ejc.2.2023.12.30.21.31.54 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 30 Dec 2023 21:31:54 -0800 (PST) Received-SPF: pass (google.com: domain of belouargamohamed@gmail.com designates 2a00:1450:4864:20::430 as permitted sender) client-ip=2a00:1450:4864:20::430; Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3373a30af67so397689f8f.0 for ; Sat, 30 Dec 2023 21:31:54 -0800 (PST) X-Received: by 2002:a5d:4590:0:b0:336:7c5e:5710 with SMTP id p16-20020a5d4590000000b003367c5e5710mr4749380wrq.110.1704000713744; Sat, 30 Dec 2023 21:31:53 -0800 (PST) Received: from localhost.localdomain ([79.93.180.101]) by smtp.gmail.com with ESMTPSA id c12-20020a5d4ccc000000b003371e7113d4sm5402798wrt.24.2023.12.30.21.31.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Dec 2023 21:31:53 -0800 (PST) From: belouargamohamed@gmail.com To: swupdate@googlegroups.com Cc: f.lahoudere@technologyandstrategy.com, BELOUARGA Mohamed Subject: [swupdate] [PATCH] Avoid giving invalid arguments to memcpy Date: Sun, 31 Dec 2023 06:31:49 +0100 Message-Id: <20231231053149.148563-1-m.belouarga@technologyandstrategy.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Original-Sender: belouargamohamed@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=S6wGCEUQ; spf=pass (google.com: domain of belouargamohamed@gmail.com designates 2a00:1450:4864:20::430 as permitted sender) smtp.mailfrom=belouargamohamed@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , From: BELOUARGA Mohamed Giving NULL pointer or size equal to 0 to memcpy can result in an undefined behaviour Signed-off-by: BELOUARGA Mohamed --- handlers/remote_handler.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/handlers/remote_handler.c b/handlers/remote_handler.c index c4b83af..aa2b427 100644 --- a/handlers/remote_handler.c +++ b/handlers/remote_handler.c @@ -48,7 +48,10 @@ static void RHset_payload(struct RHmsg *self, const void *body, size_t size) { zmq_msg_t *msg = &self->frame[FRAME_BODY]; zmq_msg_init_size(msg, size); - memcpy (zmq_msg_data(msg), body, size); + if ((body != NULL) && (size > 0)) + { + memcpy (zmq_msg_data(msg), body, size); + } } static int RHmsg_send_cmd(struct RHmsg *self, void *request)