Re: [PATCH] xfs: xattr: replace strncpy and check for truncation

2024-04-09 Thread Darrick J. Wong
On Tue, Apr 09, 2024 at 05:27:34PM -0700, Justin Stitt wrote: > On Tue, Apr 9, 2024 at 5:23 PM Justin Stitt wrote: > > > > Hi, > > > > On Tue, Apr 9, 2024 at 6:32 AM Christoph Hellwig wrote: > > > > > > On Fri, Apr 05, 2024 at 07:45:08PM +, Justin Stitt wrote: > > > > - memcpy(offset,

Re: [PATCH] xfs: xattr: replace strncpy and check for truncation

2024-04-09 Thread Justin Stitt
On Tue, Apr 9, 2024 at 5:23 PM Justin Stitt wrote: > > Hi, > > On Tue, Apr 9, 2024 at 6:32 AM Christoph Hellwig wrote: > > > > On Fri, Apr 05, 2024 at 07:45:08PM +, Justin Stitt wrote: > > > - memcpy(offset, prefix, prefix_len); > > > - offset += prefix_len; > > > -

Re: [PATCH] xfs: xattr: replace strncpy and check for truncation

2024-04-09 Thread Justin Stitt
Hi, On Tue, Apr 9, 2024 at 6:32 AM Christoph Hellwig wrote: > > On Fri, Apr 05, 2024 at 07:45:08PM +, Justin Stitt wrote: > > - memcpy(offset, prefix, prefix_len); > > - offset += prefix_len; > > - strncpy(offset, (char *)name, namelen); /* real name > > */ > > -

Re: [PATCH] xfs: xattr: replace strncpy and check for truncation

2024-04-09 Thread Christoph Hellwig
On Fri, Apr 05, 2024 at 07:45:08PM +, Justin Stitt wrote: > - memcpy(offset, prefix, prefix_len); > - offset += prefix_len; > - strncpy(offset, (char *)name, namelen); /* real name */ > - offset += namelen; > - *offset = '\0'; > + > + combined_len =

[PATCH] xfs: xattr: replace strncpy and check for truncation

2024-04-05 Thread Justin Stitt
strncpy is deprecated and as such we should prefer less ambiguous and more robust string interfaces [1]. There's a lot of manual memory management to get a prefix and name into a string. Let's use an easier to understand and more robust interface in scnprintf() to accomplish the same task while