From patchwork Tue Jul 19 08:52:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mengdong.lin@linux.intel.com X-Patchwork-Id: 9237803 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 83F1A60574 for ; Tue, 19 Jul 2016 16:13:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73E0326E64 for ; Tue, 19 Jul 2016 16:13:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68AC72711E; Tue, 19 Jul 2016 16:13:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E537026E64 for ; Tue, 19 Jul 2016 16:13:17 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id E3DB1266BD1; Tue, 19 Jul 2016 18:13:16 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 69917266C74; Tue, 19 Jul 2016 12:09:42 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id D3BF3266C74; Tue, 19 Jul 2016 12:09:41 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by alsa0.perex.cz (Postfix) with ESMTP id A7299266D0D for ; Tue, 19 Jul 2016 10:47:44 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 19 Jul 2016 01:47:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,388,1464678000"; d="scan'208";a="849028655" Received: from amanda-haswell-pc.sh.intel.com ([10.239.159.169]) by orsmga003.jf.intel.com with ESMTP; 19 Jul 2016 01:47:41 -0700 From: mengdong.lin@linux.intel.com To: alsa-devel@alsa-project.org, broonie@kernel.org Date: Tue, 19 Jul 2016 16:52:48 +0800 Message-Id: X-Mailer: git-send-email 2.5.0 In-Reply-To: References: Cc: tiwai@suse.de, mengdong.lin@intel.com, Mengdong Lin , liam.r.girdwood@intel.com, o-takashi@sakamocchi.jp Subject: [alsa-devel] [PATCH 3/3] topology: Check address and length before string copy X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mengdong Lin Signed-off-by: Mengdong Lin diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h index 4d79aa7..cfde4cc 100644 --- a/src/topology/tplg_local.h +++ b/src/topology/tplg_local.h @@ -253,6 +253,9 @@ struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg, static inline void elem_copy_text(char *dest, const char *src, int len) { + if (!dest || !src || !len) + return; + strncpy(dest, src, len); dest[len - 1] = 0; }