From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54BB32C027F for ; Tue, 28 Apr 2026 08:56:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.185 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777366569; cv=none; b=LxWltSzHJD24DmBkgO3pyPFj/n3p1Y4lmt3DFLg2zP9AiMA+z5RmfWIAXvU6Na1zu+GVhp46Mgt7ZMAgVeFNyWynEz9ywqmfr5baFnMpNeOtnXTNxJVZeY2edTJbYEyLPuW6b66BPi9JNfrBkNyO1wYvOQAdBlYARoC83KM2GUg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777366569; c=relaxed/simple; bh=BCFdaxF3AZItauoN4b2AJfijk085TIIk/9Q4FJzky+E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AGeK7kRaADy9o2nKIfnLMDag07k6Sx7BHtYszyFKoLp2bQEdJ1ZT+fllJBKZ903ZH3RzM6/T7ck/hFHOHrYAIbfswsKYqqWwkMUbeGbOaoGgrvOpNQcS1otUvlvaMgbrGrjbHMI4ouOMqElPSb93i9Toefh1U7cb4EuP/0yaGdw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=tkGHtlmp; arc=none smtp.client-ip=91.218.175.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="tkGHtlmp" Date: Tue, 28 Apr 2026 10:55:59 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1777366563; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=cbIa2m53wWyfcDneE98vkFjqEz1MllZsOU1Y3EHLveA=; b=tkGHtlmpCCRmzn952vbxxApDkea+uQh7nUI7IxuGxgSDTkmnz6cCTCT1gI7KtyKbIIJFmK 6ub3FAUTLdgCKlED27eq2bYsEF1IKMhXBerNIW97RVVV3EbEGD5b+GewqSLj4MGtEGeJp/ ILxisjo7zTqwcObgeItBEEt0/C+3Xyc= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Thorsten Blum To: Eli Billauer Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: Re: [PATCH] char: xillybus: use strscpy() in init_chrdev Message-ID: References: <20260427173730.418592-3-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT On Tue, Apr 28, 2026 at 10:37:49AM +0200, Eli Billauer wrote: > Hello, > > On 27/04/2026 19:37, Thorsten Blum wrote: > > > if (!enumerate) > > - snprintf(unit->name, UNITNAMELEN, "%s", prefix); > > + strscpy(unit->name, prefix); > > for (i = 0; enumerate; i++) { > > snprintf(unit->name, UNITNAMELEN, "%s_%02d", > > snprintf() is used deliberately for code clarity: It makes a simple visual > contrast with the use of snprintf() three rows below. As this call takes > place only once for each physical hardware device handled by the driver, the > advantage in optimizing this function call is negligible. > > And even though it's formally OK to use strscpy() with two arguments, and > let the compilation machinery find out the length of the char array, I have > to admit that it gives me the chills. Buffer overflow and that. You probably mean strcpy()? strscpy() is safe regarding buffer overflow.