From patchwork Tue Mar 8 20:40:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 8537611 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 14B61C0553 for ; Tue, 8 Mar 2016 20:41:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 38C912011D for ; Tue, 8 Mar 2016 20:41:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9642820131 for ; Tue, 8 Mar 2016 20:41:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751836AbcCHUlY (ORCPT ); Tue, 8 Mar 2016 15:41:24 -0500 Received: from mail-wm0-f52.google.com ([74.125.82.52]:35215 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751693AbcCHUlR (ORCPT ); Tue, 8 Mar 2016 15:41:17 -0500 Received: by mail-wm0-f52.google.com with SMTP id l68so149513976wml.0 for ; Tue, 08 Mar 2016 12:41:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9qa0Dyn7smmxWRwlYgr/YRGwGUOzK9votEtcT5pipJA=; b=QdrZIQbb0ipV7T7oXcuvUxNQ+ZMkDgAgyjFAnQdGTJ9YYG8vhh6ZnEmZp/Y6nulPYT 72N/Rl4UAsKV+OGIC3hsgfI8Np3rp+PcbUI2GUIC5dazrovcltBCFGFbofQEHOx+7LwM wfH5k2GnvvfA4ccl0paALFMzEVXbSyoRA0hQA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9qa0Dyn7smmxWRwlYgr/YRGwGUOzK9votEtcT5pipJA=; b=R+vzXWQG0IBbdaALn4ylE4BkwMW1QtfxBu6phwL+zw79cNF517bFDdYTqEkF6qLHeG SFJMt7Br/S5aLSley7Q0IrBWvhTozfdtvxTH80w1Ifp7zLGRdGsbyJpTo6dcRfk8BhdY fx2+tV6xngmF/fBbwCa9rjopVdOGOpd3tXmGgPnRZDp+UWujTS0rCkLrWcDUvYRPh3/w pifuvE9QDlH1nVWIinpl7V5tBrC1SZFMec9Vbh1vKtasO+WtzQzaT0uV4C4pSOJrsJqf 9mKpoQFxjr3h+gWk2AiTVZ+XfGExzmZzRl8OpTiQaO/e3R+Hf6fNUq8ZaHI+3mMZjaRJ ZChQ== X-Gm-Message-State: AD7BkJKENYnfx7y8xP+/tvc4Pp79n+l4uGK8g0Y7L8225cd28noE4oXx3FmU9IU1Z9F7VQ== X-Received: by 10.194.190.6 with SMTP id gm6mr31729271wjc.115.1457469666186; Tue, 08 Mar 2016 12:41:06 -0800 (PST) Received: from wildmoose.dk (lvps87-230-87-209.dedicated.hosteurope.de. [87.230.87.209]) by smtp.gmail.com with ESMTPSA id b203sm5088471wmh.8.2016.03.08.12.41.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Mar 2016 12:41:05 -0800 (PST) From: Rasmus Villemoes To: Kees Cook , Andrew Morton , Mauro Carvalho Chehab Cc: Rasmus Villemoes , mjpeg-users@lists.sourceforge.net, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC 4/7] drivers/media/pci/zoran: avoid fragile snprintf use Date: Tue, 8 Mar 2016 21:40:51 +0100 Message-Id: <1457469654-17059-5-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1457469654-17059-1-git-send-email-linux@rasmusvillemoes.dk> References: <1457469654-17059-1-git-send-email-linux@rasmusvillemoes.dk> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Appending to a string by doing snprintf(buf, bufsize, "%s...", buf, ...) is not guaranteed to work. Signed-off-by: Rasmus Villemoes --- drivers/media/pci/zoran/videocodec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/zoran/videocodec.c b/drivers/media/pci/zoran/videocodec.c index c01071635290..13a3c07cd259 100644 --- a/drivers/media/pci/zoran/videocodec.c +++ b/drivers/media/pci/zoran/videocodec.c @@ -116,8 +116,9 @@ videocodec_attach (struct videocodec_master *master) goto out_module_put; } - snprintf(codec->name, sizeof(codec->name), - "%s[%d]", codec->name, h->attached); + res = strlen(codec->name); + snprintf(codec->name + res, sizeof(codec->name) - res, + "[%d]", h->attached); codec->master_data = master; res = codec->setup(codec); if (res == 0) {