[openssh-commits] [openssh] 01/05: upstream: Avoid an unnecessary xstrdup in rm_env() when matching

git+noreply at mindrot.org git+noreply at mindrot.org
Wed Apr 27 21:33:47 AEST 2022


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

dtucker pushed a commit to branch master
in repository openssh.

commit fe9d87a6800a7a33be08f4d5ab662a758055ced2
Author: millert at openbsd.org <millert at openbsd.org>
Date:   Wed Apr 20 15:56:49 2022 +0000

    upstream: Avoid an unnecessary xstrdup in rm_env() when matching
    
    patterns. Since match_pattern() doesn't modify its arguments (they are
    const), there is no need to make an extra copy of the strings in
    options->send_env. From Martin Vahlensieck
    
    OpenBSD-Commit-ID: 2c9db31e3f4d3403b49642c64ee048b2a0a39351
---
 readconf.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/readconf.c b/readconf.c
index f26fabaa..55d2b1a3 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: readconf.c,v 1.366 2022/02/08 08:59:12 dtucker Exp $ */
+/* $OpenBSD: readconf.c,v 1.367 2022/04/20 15:56:49 millert Exp $ */
 /*
  * Author: Tatu Ylonen <ylo at cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -754,19 +754,15 @@ static void
 rm_env(Options *options, const char *arg, const char *filename, int linenum)
 {
 	int i, j, onum_send_env = options->num_send_env;
-	char *cp;
 
 	/* Remove an environment variable */
 	for (i = 0; i < options->num_send_env; ) {
-		cp = xstrdup(options->send_env[i]);
-		if (!match_pattern(cp, arg + 1)) {
-			free(cp);
+		if (!match_pattern(options->send_env[i], arg + 1)) {
 			i++;
 			continue;
 		}
 		debug3("%s line %d: removing environment %s",
-		    filename, linenum, cp);
-		free(cp);
+		    filename, linenum, options->send_env[i]);
 		free(options->send_env[i]);
 		options->send_env[i] = NULL;
 		for (j = i; j < options->num_send_env - 1; j++) {

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


More information about the openssh-commits mailing list