From patchwork Sat Jul 10 22:10:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 111252 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6AMJdgR010868 for ; Sat, 10 Jul 2010 22:19:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753527Ab0GJWTc (ORCPT ); Sat, 10 Jul 2010 18:19:32 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:60431 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752035Ab0GJWTa (ORCPT ); Sat, 10 Jul 2010 18:19:30 -0400 Received: by fxm14 with SMTP id 14so1730166fxm.19 for ; Sat, 10 Jul 2010 15:19:29 -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=maikhIH77YYDSYK0tCUxOkD5BcbFiocJtxchcXRU2MI=; b=AHiNU9SvcjPsf9QfdOJ7TZaw05/shFspXmepqFcYwG+8hm+/LuJZvs7R6sil68MhQC cBRWM/yBd2x00fdPNbqOtk+x1MEdYCScnWV+KshGuFU5ans8pl5Vb4v4lOHjhEXvbbWS s0y8+Ouaxj8Pikaz4PeYX3L6dZxtteEr56d2I= 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=Gx5AovNI+hgr/jsi6vmYK13HYuLQ5JvZ/h6EgqU3rSlwLi8BBCgEm3rR1Nxa0iqpuM AegyxYzRRhPB9He9Mw6evcv+4raikEYXcZaAUb+FXCUrFb6FV20JMJ+k+polL7lgNoV9 LzvgpaW1QCgcPE3xhb6bmlYx5pQy+ZDHDoiok= Received: by 10.223.107.10 with SMTP id z10mr9778016fao.87.1278800368933; Sat, 10 Jul 2010 15:19:28 -0700 (PDT) Received: from bicker ([205.177.176.130]) by mx.google.com with ESMTPS id 24sm5202797far.36.2010.07.10.15.15.48 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 10 Jul 2010 15:19:28 -0700 (PDT) Date: Sun, 11 Jul 2010 00:10:42 +0200 From: Dan Carpenter To: Jouni Malinen Cc: "John W. Linville" , Martin Decky , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] hostap: fixup strlen() math Message-ID: <20100710221042.GA14911@bicker> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 10 Jul 2010 22:19:39 +0000 (UTC) In hostap_add_interface() we do: sprintf(dev->name, "%s%s", prefix, name); dev->name has IFNAMSIZ (16) characters. prefix is local->dev->name. name is "wds%d" strlen() returns the number of characters in the string not counting the NULL so if we have a string with 11 characters we get "12345678901wds%d" which is 16 characters and a NULL so we're past the end of the array. Signed-off-by: Dan Carpenter --- To unsubscribe from this list: send the line "unsubscribe linux-wireless" 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/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c index eb57d1e..f1bc258 100644 --- a/drivers/net/wireless/hostap/hostap_main.c +++ b/drivers/net/wireless/hostap/hostap_main.c @@ -186,7 +186,7 @@ int prism2_wds_add(local_info_t *local, u8 *remote_addr, return -ENOBUFS; /* verify that there is room for wds# postfix in the interface name */ - if (strlen(local->dev->name) > IFNAMSIZ - 5) { + if (strlen(local->dev->name) >= IFNAMSIZ - 5) { printk(KERN_DEBUG "'%s' too long base device name\n", local->dev->name); return -EINVAL;