Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033130AbbKFV6U (ORCPT ); Fri, 6 Nov 2015 16:58:20 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:36517 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030287AbbKFV6T (ORCPT ); Fri, 6 Nov 2015 16:58:19 -0500 Date: Sat, 7 Nov 2015 00:57:55 +0300 From: Dan Carpenter To: Andy Shevchenko Cc: Ivan Safonov , devel@driverdev.osuosl.org, Bryan Paul , Vaishali Thakkar , Greg Kroah-Hartman , "linux-kernel@vger.kernel.org" , Larry Finger Subject: Re: [PATCH 2/3] staging: rtl8188eu: if/else replaced by min_t Message-ID: <20151106215755.GC18797@mwanda> References: <20151106151846.GA12146@alpha.sfu-kras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1328 Lines: 35 On Fri, Nov 06, 2015 at 11:42:50PM +0200, Andy Shevchenko wrote: > On Fri, Nov 6, 2015 at 5:18 PM, Ivan Safonov wrote: > > psecuritypriv->authenticator_ie[0] = (unsigned char)psecnetwork->IELength; > > > > - if ((psecnetwork->IELength-12) < (256-1)) > > - memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], psecnetwork->IELength-12); > > - else > > - memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], (256-1)); > > + memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], min_t(int, psecnetwork->IELength - 12, 256 - 1)); > > > > Run checkpatch.pl. The long line was there in the original so it's forgivable but probably should be changed in v2. The main thing though is that this looks to introduce a memory corruption but because the original used unsigned comparison and we have changed it to doing "int" comparison. It should be u32 like in the original code. Or size_t would be ok too. > > 256 looks like sizeof(…). Yup. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/