From nobody Tue Feb 10 16:22:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1614274950; cv=none; d=zohomail.com; s=zohoarc; b=a1L38hZPEvy8hRJ7iOG4/FTZ8k4zn5pYcUMnhmf4ZRyVRzn3gzniklYV0u0V69Zg91Fn7MYP985dbUrvJOpMOZqEvLevvf3ysEL4i0vL3kbDgCq6a+t3kA9foyXV+2MUQS5RTfIrRiN/mTDlAEpPkmgV8tQi/SFH8GZM8bbGRJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614274950; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=JuTt5+fVqpN12bzr+SQUOtZ9U/AniX5wCdCX0Q2WLao=; b=kFNUo4mTF85se+ekimvIg9vDjEbkII7ZKE6TL4tdZOOGyfc8dzsEQbehu09nPi0fk2Xru63R1Mqfe9XAxh1z6QECN+AnXBDzCfh/+6BL+YW1eKwoCg98h5FGyDU7PUtwMjsr1O/bj2CusJpox6R57nDSfeH3vxQ+KqpBh9XDQwA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1614274950738464.6006196223166; Thu, 25 Feb 2021 09:42:30 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.89892.169803 (Exim 4.92) (envelope-from ) id 1lFKeW-0006C6-Ps; Thu, 25 Feb 2021 17:42:16 +0000 Received: by outflank-mailman (output) from mailman id 89892.169803; Thu, 25 Feb 2021 17:42:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFKeW-0006By-LB; Thu, 25 Feb 2021 17:42:16 +0000 Received: by outflank-mailman (input) for mailman id 89892; Thu, 25 Feb 2021 17:42:15 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFKeV-0006A2-F1 for xen-devel@lists.xenproject.org; Thu, 25 Feb 2021 17:42:15 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFKeU-0005qs-Fw; Thu, 25 Feb 2021 17:42:14 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lFKeU-00032g-7E; Thu, 25 Feb 2021 17:42:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=JuTt5+fVqpN12bzr+SQUOtZ9U/AniX5wCdCX0Q2WLao=; b=5i5uy41NOnXHp39CeUAjMnJZn Jvu+LoaUW7sd/DbtG/GNjoJ1frUp/JDVUQlRXaPw328ObUdirePteN4lkVfScrXb3vgH5ys6nglEN kSG18A/Lwbx+m4L4u7aikIeWRoTxrC5zcrBBL7Mo8C53CVi76QpxC5nlhHEXnptLGPIek=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: raphning@amazon.co.uk, iwj@xenproject.org, Julien Grall , Wei Liu , Juergen Gross Subject: [PATCH for-4.15 2/5] tools/xenstored: Avoid unnecessary talloc_strdup() in do_lu_start() Date: Thu, 25 Feb 2021 17:41:28 +0000 Message-Id: <20210225174131.10115-3-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210225174131.10115-1-julien@xen.org> References: <20210225174131.10115-1-julien@xen.org> X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall At the moment, the return of talloc_strdup() is not checked. This means we may dereference a NULL pointer if the allocation failed. However, it is pointless to allocate the memory as send_reply() will copy the data to a different buffer. So drop the use of talloc_strdup(). This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc. Fixes: af216a99fb4a ("tools/xenstore: add the basic framework for doing the= live update") Signed-off-by: Julien Grall Reviewed-by: Juergen Gross --- tools/xenstore/xenstored_control.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/xenstore/xenstored_control.c b/tools/xenstore/xenstored_= control.c index e8a501acdb62..8eb57827765c 100644 --- a/tools/xenstore/xenstored_control.c +++ b/tools/xenstore/xenstored_control.c @@ -638,7 +638,6 @@ static bool do_lu_start(struct delayed_request *req) { time_t now =3D time(NULL); const char *ret; - char *resp; =20 if (!lu_check_lu_allowed()) { if (now < lu_status->started_at + lu_status->timeout) @@ -660,8 +659,7 @@ static bool do_lu_start(struct delayed_request *req) out: talloc_free(lu_status); =20 - resp =3D talloc_strdup(req->in, ret); - send_reply(lu_status->conn, XS_CONTROL, resp, strlen(resp) + 1); + send_reply(lu_status->conn, XS_CONTROL, ret, strlen(ret) + 1); =20 return true; } --=20 2.17.1