From patchwork Mon Jul 26 07:23:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 59894 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 26692B6F11 for ; Mon, 26 Jul 2010 17:24:37 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753748Ab0GZHY0 (ORCPT ); Mon, 26 Jul 2010 03:24:26 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:39939 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753747Ab0GZHYZ (ORCPT ); Mon, 26 Jul 2010 03:24:25 -0400 Received: by fxm14 with SMTP id 14so5914219fxm.19 for ; Mon, 26 Jul 2010 00:24:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=ARu/P+uFEeUhgs6QhFGrfBIcMGrq+LQcqMmF6T532As=; b=I0OdyawYe396XQjMqMtD7FXboUOxgWJlnayxxVQUF3hoIuP8PhJq67j+h3TtJzHlmY +1WqOV8s2pQsw4mWBBqjaDuV97cno8yerLArUuhb+V+uRkUpgXCWhJh0HeTSzR1pOSIq oRk1o2h6iQxEFmIWAPRsiC4Su9ZsqMP1pX/q8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=ZDYThB/TLlo0gG15p81QjHAotRoncA2pTf7cWYQxT3HluP2FXLNijUcUfDa7xHtQ9x uga6/JBKZf52Mc6yu9QvNUMZEA2nzUmJSqMoT0buJOC3KJ1Lsku7k2xvQFD5YZkqH+nB yLAzLBZ4kPlimc9adsC1e/h1ei+R0NQWl4VHE= Received: by 10.86.27.14 with SMTP id a14mr4404144fga.50.1280129063577; Mon, 26 Jul 2010 00:24:23 -0700 (PDT) Received: from bicker ([205.177.176.130]) by mx.google.com with ESMTPS id w11sm1262603fao.13.2010.07.26.00.24.15 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 26 Jul 2010 00:24:22 -0700 (PDT) Date: Mon, 26 Jul 2010 09:23:59 +0200 From: Dan Carpenter To: Sjur Braendeland Cc: "David S. Miller" , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] caif: handle snprintf() return Message-ID: <20100726072358.GK26313@bicker> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org snprintf() returns the number of bytes that would have been written. It can be larger than the size of the buffer. The current code won't overflow, but people cut and paste this stuff so lets do it right and also make the static checkers happy. Signed-off-by: Dan Carpenter --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/caif/caif_spi.c b/drivers/net/caif/caif_spi.c index 6c94803..f5058ff 100644 --- a/drivers/net/caif/caif_spi.c +++ b/drivers/net/caif/caif_spi.c @@ -165,6 +165,9 @@ static ssize_t dbgfs_state(struct file *file, char __user *user_buf, len += snprintf((buf + len), (DEBUGFS_BUF_SIZE - len), "Next RX len: %d\n", cfspi->rx_npck_len); + if (len > DEBUGFS_BUF_SIZE) + len = DEBUGFS_BUF_SIZE; + size = simple_read_from_buffer(user_buf, count, ppos, buf, len); kfree(buf);