From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexey Dobriyan Subject: Re: [PATCH] net: Allow mac_pton() to work on non-NULL terminated strings Date: Fri, 23 Feb 2018 23:41:04 +0300 Message-ID: <20180223204104.GA15686@avx2> References: <20180223182006.GA2116@avx2> <20180223201748.14328-1-stefan@the2masters.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: andrew@lunn.ch, linux@arm.linux.org.uk, jason@lakedaemon.net, netdev@vger.kernel.org, "\[ 4 . 4+ \]" , linux-arm-kernel@lists.infradead.org, gregory.clement@free-electrons.com, andriy.shevchenko@linux.intel.com, dv@vollmann.ch To: Stefan Hellermann Return-path: Content-Disposition: inline In-Reply-To: <20180223201748.14328-1-stefan@the2masters.de> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org List-Id: netdev.vger.kernel.org On Fri, Feb 23, 2018 at 09:17:48PM +0100, Stefan Hellermann wrote: > @@ -8,10 +8,6 @@ bool mac_pton(const char *s, u8 *mac) > { > int i; > > - /* XX:XX:XX:XX:XX:XX */ > - if (strlen(s) < 3 * ETH_ALEN - 1) > - return false; > - > /* Don't dirty result unless string is valid MAC. */ > for (i = 0; i < ETH_ALEN; i++) { > if (!isxdigit(s[i * 3]) || !isxdigit(s[i * 3 + 1])) Short string will bail in the loop, indeed. Reviewed-by: Alexey Dobriyan From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 23 Feb 2018 23:41:04 +0300 From: Alexey Dobriyan To: Stefan Hellermann Cc: netdev@vger.kernel.org, andriy.shevchenko@linux.intel.com, andrew@lunn.ch, linux@arm.linux.org.uk, jason@lakedaemon.net, dv@vollmann.ch, gregory.clement@free-electrons.com, linux-arm-kernel@lists.infradead.org, "[ 4 . 4+ ]" Subject: Re: [PATCH] net: Allow mac_pton() to work on non-NULL terminated strings Message-ID: <20180223204104.GA15686@avx2> References: <20180223182006.GA2116@avx2> <20180223201748.14328-1-stefan@the2masters.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180223201748.14328-1-stefan@the2masters.de> Sender: netdev-owner@vger.kernel.org List-ID: On Fri, Feb 23, 2018 at 09:17:48PM +0100, Stefan Hellermann wrote: > @@ -8,10 +8,6 @@ bool mac_pton(const char *s, u8 *mac) > { > int i; > > - /* XX:XX:XX:XX:XX:XX */ > - if (strlen(s) < 3 * ETH_ALEN - 1) > - return false; > - > /* Don't dirty result unless string is valid MAC. */ > for (i = 0; i < ETH_ALEN; i++) { > if (!isxdigit(s[i * 3]) || !isxdigit(s[i * 3 + 1])) Short string will bail in the loop, indeed. Reviewed-by: Alexey Dobriyan From mboxrd@z Thu Jan 1 00:00:00 1970 From: adobriyan@gmail.com (Alexey Dobriyan) Date: Fri, 23 Feb 2018 23:41:04 +0300 Subject: [PATCH] net: Allow mac_pton() to work on non-NULL terminated strings In-Reply-To: <20180223201748.14328-1-stefan@the2masters.de> References: <20180223182006.GA2116@avx2> <20180223201748.14328-1-stefan@the2masters.de> Message-ID: <20180223204104.GA15686@avx2> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Fri, Feb 23, 2018 at 09:17:48PM +0100, Stefan Hellermann wrote: > @@ -8,10 +8,6 @@ bool mac_pton(const char *s, u8 *mac) > { > int i; > > - /* XX:XX:XX:XX:XX:XX */ > - if (strlen(s) < 3 * ETH_ALEN - 1) > - return false; > - > /* Don't dirty result unless string is valid MAC. */ > for (i = 0; i < ETH_ALEN; i++) { > if (!isxdigit(s[i * 3]) || !isxdigit(s[i * 3 + 1])) Short string will bail in the loop, indeed. Reviewed-by: Alexey Dobriyan