From patchwork Thu Aug 17 13:26:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 802651 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4010:c07::23f; helo=mail-lf0-x23f.google.com; envelope-from=swupdate+bncbdd6bwv65qpbb4ft23gakgqesc7gi3q@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="LGJiUcsq"; dkim-atps=neutral Received: from mail-lf0-x23f.google.com (mail-lf0-x23f.google.com [IPv6:2a00:1450:4010:c07::23f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xY6VD56Kzz9t4V for ; Thu, 17 Aug 2017 23:28:19 +1000 (AEST) Received: by mail-lf0-x23f.google.com with SMTP id 71sf832436lfs.1 for ; Thu, 17 Aug 2017 06:28:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1502976497; cv=pass; d=google.com; s=arc-20160816; b=VKFSaTEdEr695/C+4QYd752c+XKDKAeKa0/EnababQpMjgr0FWZ1knMZRujbwMENE8 oQpYKNbtHiqK2IBgIbFaNTwrZSBtMzkN/kXZABk00C9UWhR68TDjqjcZINKsySpA1CSy YD3Wbkh+lWY9bGy2Rw0ObiBhirEhG/+tUhQkXSyYYvn7pUxLhZCTRRC+Z13/efb6c7BV tDjsE+3DWrtxUXKH0pbBYAvaIIDZG8JhiYgWktNxJA7ZH26LtsLs8Nmc+nEhyjO1vH0W VZCYQoD6AyWfKHV/KYMzTkTP6xieglbUJi8CZWLLSnE7hM/EFCv/tZm+M7Ib2Rxe/TQB XSMQ== 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:message-id:date:subject:cc:to:from :arc-authentication-results:arc-message-signature:mime-version :sender:dkim-signature:arc-authentication-results; bh=hP3hWtz/Z1/kFwuJyPEO32/o/5Bjm9JSbFHQlDDY+wE=; b=oD54GnzjhLnnx05CVM2X3guoVtqmMSUfnWti2NREAJ73S1PJC+crlMNZsE84cPm8eD 9vQyuiytEkmfjmBLRu6PDWdiPOaE808NIqgKJ78Y1paFLNxpuRQLGhSWmWoW0AozEHXh wIzTqNRzPMNvT+ljiE9sP/EFxZ9JyVp4Ht2Hr4mWHi4X15LwIjUgRogcCZPLEvSNFhkS 0MvL+PqV5qNxoPQmv3DLkb0SnwFx7o7kXpURjN7tuljVCiB1jUlqEL1bQBzGsVlt971v OYAsVXnhAteZOoSe+NI5kHvygXWIXuBjn66AnI3boDdVhz5N+MHMgyi2/HGoOqcULitd qeFw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 192.35.17.2 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=hP3hWtz/Z1/kFwuJyPEO32/o/5Bjm9JSbFHQlDDY+wE=; b=LGJiUcsqNovEdhxS1m7yLqUWUK3ADLcjhP+xOQIZNaPBe73wWnv/fB+IkW/NH+tTco 0t4HNEv81Ox2/4d+oyNVnMMKXcDOsOjYwU4VgHmlud1xeE0Sw7aJBkiXPZy/MOcEFrSx uJvQZ5vDJqHi0uKZKuvHxT9dHBZFPSk8xNhHSLZsHQbYYj3swiBEGBHSh9T1hY7SoUWX JVfsKOaABIx4YN945Nmz4LfCeQDE3barD032zcBpnG1rcen/lqlwl7xihTpm7/IcKnLc wpNvugNsoL5Bw7o/7eWO0FJTeNhncjvDbT2bvkCXW6gj125A1lsCu/gC4r7WhYN2l2+2 TBLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=hP3hWtz/Z1/kFwuJyPEO32/o/5Bjm9JSbFHQlDDY+wE=; b=Hu3lezL7Rek/7hOVX+95EdseRmYHyx33tz86MmXqIj8YkV0BJMeEjUMMrvC+2W6S7k NjJgcRefkt5rk4adQc+O+FfHtQAatcK0aL1Iv6izgTDNTFwEIj05KyeslY3f1HBMoZK0 lBexdu3mI87OBvxYdDgbWETm8UZf7OfTqn4jQvPcEifgySieySPWse5mSTLXQgGiS5uY WiNVsfriiL80tjbF9NNe6//awYxQ/9YhYJet1SFWBMZo25rDReDe6PpknMAxWoAnW15a Qpof06zLVXxlPfMO4Q6JXg1bBa2ORfqq1zs8gRMN+rtLB6sK+TdRntO+mkiFHuvwQN0P PJnQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AHYfb5iX1RBWPjyBXFCpWMyVtw0y0OvnkuEspvvPFB/t/orDEnqOzErZ Mk3gobSvWRXbiA== X-Received: by 10.46.32.135 with SMTP id g7mr10224lji.18.1502976497143; Thu, 17 Aug 2017 06:28:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.25.23.94 with SMTP id n91ls227937lfi.9.gmail; Thu, 17 Aug 2017 06:28:16 -0700 (PDT) X-Received: by 10.25.233.88 with SMTP id g85mr24236lfh.38.1502976496492; Thu, 17 Aug 2017 06:28:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502976496; cv=none; d=google.com; s=arc-20160816; b=Q//5yl3avP+5YHkPHoyveSlVKXxk2MrVIvfZw9Fo5qUOX72NvGyDyg0ZnJbQqsI8l6 v5Xyy8a1AFEmW/e2fOk1msFVKtlnB+KwfYQ9Jh1ZCW+pxVBNdsvJVeJGHibk2k2y8YeC gch4GigUVMN31rY47zKf2Mk+afcp8ayqfu45P6GQduL0zYZS3YRIPicVZxB4Jfo5U/az nkiZiKhSwJMhhMHODIhe+oOcdoMER/XiJvxPjXbuMrUhIE4x6gd/xnGKurL39Ef8ZBpQ 66yvxBV1wESWAAHw+lTMGOkT/mNC5afUf4OAqA2bGE5wwBpKNgHUaFLWXw4A2CtWpPsW Ob7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=6EK/KhW39qhodFiYtc+Wjo9ZWBYwE6VipUmRZt3emhE=; b=RBT2DuxJhC7HsUwq2QaWhlpSH6UVBNrFiZoLMq74YZs/G4hMXUfpGWoDRBq9P+Si2l /1M3ujDiNcYTCMrW6f5Qb1TG+BzW1qyrJLtf5wg6hdSKsdT8EQT+fWiBsv8kTphvL9Ls nWRllbESoyfftpnMzkEdwbcEZzM5Gb7zYA/BN1rOemdSjQSX1CnZhrlbhuMCVTkTOahU xsXjnytOaJKMVd2mnhAigIJAsoI9YUio73JXk2myuxkMyqBut81OnprS5lU1aajEFcB1 QSdtQUJ1rRYIKX8LuR6wisdnn3mG/px2PyNYLeaoo9xzE90uWT7tavLggQWa6AKSdh7Y U9Hg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 192.35.17.2 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id o62si1568541wmo.2.2017.08.17.06.28.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Aug 2017 06:28:16 -0700 (PDT) Received-SPF: neutral (google.com: 192.35.17.2 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) client-ip=192.35.17.2; Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id v7HDSGiN004033 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 17 Aug 2017 15:28:16 +0200 Received: from MD1KR9XC.ww002.siemens.net ([139.25.68.253]) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id v7HDSG0L009095; Thu, 17 Aug 2017 15:28:16 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH resent] IPC: don't zero ipc_postupdate()'s msg parameter Date: Thu, 17 Aug 2017 15:26:14 +0200 Message-Id: <20170817132614.17160-1-christian.storm@siemens.com> X-Mailer: git-send-email 2.14.1 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 192.35.17.2 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.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: , When signaling the due execution of postupdate() via ipc_postupdate(), zero out msg preserving msg.data.instmsg.buf so that an optional message can be forwarded to postupdate(). Signed-off-by: Christian Storm --- ipc/network_ipc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ipc/network_ipc.c b/ipc/network_ipc.c index 0f346ba..6629461 100644 --- a/ipc/network_ipc.c +++ b/ipc/network_ipc.c @@ -78,7 +78,21 @@ int ipc_postupdate(ipc_message *msg) { } ssize_t ret; + char* tmpbuf = NULL; + if (msg->data.instmsg.len > 0) { + if ((tmpbuf = strndupa(msg->data.instmsg.buf, + msg->data.instmsg.len > sizeof(msg->data.instmsg.buf) + ? sizeof(msg->data.instmsg.buf) + : msg->data.instmsg.len)) == NULL) { + close(connfd); + return -1; + } + } memset(msg, 0, sizeof(*msg)); + if (tmpbuf != NULL) { + strncpy(msg->data.instmsg.buf, tmpbuf, sizeof(msg->data.instmsg.buf)); + msg->data.instmsg.len = strnlen(tmpbuf, sizeof(msg->data.instmsg.buf)); + } msg->magic = IPC_MAGIC; msg->type = POST_UPDATE; ret = write(connfd, msg, sizeof(*msg));