Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966138AbbD1Uvo (ORCPT ); Tue, 28 Apr 2015 16:51:44 -0400 Received: from mail-ig0-f173.google.com ([209.85.213.173]:38232 "EHLO mail-ig0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965988AbbD1Uvn (ORCPT ); Tue, 28 Apr 2015 16:51:43 -0400 MIME-Version: 1.0 In-Reply-To: <553FE3F0.4060803@ezchip.com> References: <20150428034859.GI889@ZenIV.linux.org.uk> <1363736428.511175.1430199310500.open-xchange@webmail.nmp.proximus.be> <20150428160523.GJ889@ZenIV.linux.org.uk> <553FE3F0.4060803@ezchip.com> Date: Tue, 28 Apr 2015 13:51:42 -0700 X-Google-Sender-Auth: aQhJxLDuvtGIpf6jFgu17wnyXfU Message-ID: Subject: Re: revert "fs/befs/linuxvfs.c: replace strncpy by strlcpy" From: Linus Torvalds To: Chris Metcalf Cc: Al Viro , Fabian Frederick , Linux Kernel Mailing List , Randy Dunlap , Rickard Strandqvist Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1180 Lines: 27 On Tue, Apr 28, 2015 at 12:48 PM, Chris Metcalf wrote: > > FWIW, I wanted to deal with some strncpy/strlcpy API issues last year > and just put a "strscpy()" function in arch/tile/gxio/mpipe.c, So quite frankly, I don't like that one either. Some people really *do* want truncation, and your strscpy() makes that impossible. Also, your strscpy() implementation is actually not thread-safe: it can return an non-terminated string if the source string isn't stable. That can certainly be a design issue ("don't do that then"), but it *can* be a possible source of security issues, so it's a bad idea in something that is supposed to be secure. And quite frankly, I think that the *only* valid reason to add another random string copy function is that you actually get it right. We don't need yet another half-arsed routine that can be easily misused. We have too many of those. Linus -- 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/