From patchwork Sat Jan 15 20:35:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 79069 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 C2ADFB6EE9 for ; Sun, 16 Jan 2011 07:36:59 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753895Ab1AOUgx (ORCPT ); Sat, 15 Jan 2011 15:36:53 -0500 Received: from mail-wy0-f174.google.com ([74.125.82.174]:56806 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752789Ab1AOUgw (ORCPT ); Sat, 15 Jan 2011 15:36:52 -0500 Received: by wyb28 with SMTP id 28so3939207wyb.19 for ; Sat, 15 Jan 2011 12:36:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=ZmlqlCDYnF1i16mTVTAlg9kVVPy/E8/5qLTY0lMb3RU=; b=oocvtPknOFhRW41dExBZMMqBlUjNuOKF7p5y1xFRrhowvlN6tZcnv5kJxRE7tUn57E 5v83JSwkySL89Q8yB6FQUHivh0Lzwrmbjz7EMyOzcsRa7+FJ0LSw2QVUcmdRFGSRiEMJ jkaWun6jjOEsFjX+5KvchIYPqJXU6IPDhT2fA= 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=Q3sAA9CLt3QYBokfg9QhdgW6qdlav8Cus91d96e5qto8Jky9zwX3PvJKdR1ovxjw9e MbQAemEv9ba5p15hnTiJmG4jRbDkbAwA130ayXHRJMQ+MLt9t0yoytxymQY5LihkbxY6 /k5+KNj/bQ797Lur8gX6F/8e7siBvnOwFMc6g= Received: by 10.227.134.142 with SMTP id j14mr2272716wbt.53.1295123755187; Sat, 15 Jan 2011 12:35:55 -0800 (PST) Received: from bicker ([41.202.225.147]) by mx.google.com with ESMTPS id s9sm1425265wby.4.2011.01.15.12.35.50 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 15 Jan 2011 12:35:53 -0800 (PST) Date: Sat, 15 Jan 2011 23:35:39 +0300 From: Dan Carpenter To: Eric Van Hensbergen Cc: "David S. Miller" , Sripathi Kodi , Venkateswararao Jujjuri , "Aneesh Kumar K.V" , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] 9p: fix min_t() casting Message-ID: <20110115203539.GF2721@bicker> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The intent here was to cap the length to USHRT_MAX, but what the code actually does is it just casts the return from strlen() to unsigned short and truncates the significant bits away. 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/net/9p/protocol.c b/net/9p/protocol.c index 1e308f2..0422581 100644 --- a/net/9p/protocol.c +++ b/net/9p/protocol.c @@ -403,7 +403,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt, const char *sptr = va_arg(ap, const char *); uint16_t len = 0; if (sptr) - len = min_t(uint16_t, strlen(sptr), + len = min_t(size_t, strlen(sptr), USHRT_MAX); errcode = p9pdu_writef(pdu, proto_version,