Hi Paul, On 3/11/23 20:29, Paul Eggert wrote: > From 7e88c5914c1fab6c4d88e1ca39d6b6319e7ee768 Mon Sep 17 00:00:00 2001 > From: Paul Eggert <egg...@cs.ucla.edu> > Date: Sat, 11 Mar 2023 00:02:45 -0800 > Subject: [PATCH 2/6] Prefer memcpy to strlcpy when either works > > memcpy is standardized and should be faster here. > * lib/gshadow.c (sgetsgent): Use memcpy not strlcpy, > since the string is known to fit. > > Signed-off-by: Paul Eggert <egg...@cs.ucla.edu> > --- > lib/gshadow.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/gshadow.c b/lib/gshadow.c > index c17af67f..1976c9a9 100644 > --- a/lib/gshadow.c > +++ b/lib/gshadow.c > @@ -128,7 +128,7 @@ void endsgent (void) > sgrbuflen = len; > } > > - strlcpy (sgrbuf, string, len); > + memcpy (sgrbuf, string, len);
While this one is less of a concern, and memcpy(3) is faster than strcpy(3), I think I'd also use strcpy(3) here. Also, the 'len' variable seems confusing, since it's really a size. Cheers, Alex > > cp = strrchr (sgrbuf, '\n'); > if (NULL != cp) { > -- > 2.37.2 > -- <http://www.alejandro-colomar.es/> GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
OpenPGP_signature
Description: OpenPGP digital signature