[openssh-commits] [openssh] 01/04: upstream: ssh: xstrdup(): use memcpy(3)

git+noreply at mindrot.org git+noreply at mindrot.org
Fri Mar 18 13:33:50 AEDT 2022


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit ce324cf58ba2840e31afeb996935800780c8fa4b
Author: cheloha at openbsd.org <cheloha at openbsd.org>
Date:   Sun Mar 13 23:27:54 2022 +0000

    upstream: ssh: xstrdup(): use memcpy(3)
    
    Copying the given string into the buffer with strlcpy(3) confers no
    benefit in this context because we have already determined the
    string's length with strlen(3) in order to allocate that buffer.
    
    Thread: https://marc.info/?l=openbsd-tech&m=164687525802691&w=2
    
    ok dtucker@ millert@
    
    OpenBSD-Commit-ID: f8bfc082e36e2d2dc4e1feece02fe274155ca11a
---
 xmalloc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/xmalloc.c b/xmalloc.c
index b48d33bb..67191e3f 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xmalloc.c,v 1.36 2019/11/12 22:32:48 djm Exp $ */
+/* $OpenBSD: xmalloc.c,v 1.37 2022/03/13 23:27:54 cheloha Exp $ */
 /*
  * Author: Tatu Ylonen <ylo at cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -91,8 +91,7 @@ xstrdup(const char *str)
 
 	len = strlen(str) + 1;
 	cp = xmalloc(len);
-	strlcpy(cp, str, len);
-	return cp;
+	return memcpy(cp, str, len);
 }
 
 int

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list