]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: fix crash in recallocarray when deleting SendEnv
authordjm@openbsd.org <djm@openbsd.org>
Wed, 27 May 2020 21:25:18 +0000 (21:25 +0000)
committerDarren Tucker <dtucker@dtucker.net>
Thu, 28 May 2020 00:25:18 +0000 (10:25 +1000)
variables; spotted by & ok sthen@

OpenBSD-Commit-ID: b881e8e849edeec5082b5c0a87d8d7cff091a8fd

readconf.c

index 2afcbaeca3d648153d18cfb487abcc3a41973217..63ed7fd5f5cafca96b4aebf6c0c5fd4137d25059 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: readconf.c,v 1.329 2020/04/24 03:33:21 dtucker Exp $ */
+/* $OpenBSD: readconf.c,v 1.330 2020/05/27 21:25:18 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -735,7 +735,7 @@ match_cfg_line(Options *options, char **condition, struct passwd *pw,
 static void
 rm_env(Options *options, const char *arg, const char *filename, int linenum)
 {
-       int i, j;
+       int i, j, onum_send_env = options->num_send_env;
        char *cp;
 
        /* Remove an environment variable */
@@ -758,6 +758,11 @@ rm_env(Options *options, const char *arg, const char *filename, int linenum)
                options->num_send_env--;
                /* NB. don't increment i */
        }
+       if (onum_send_env != options->num_send_env) {
+               options->send_env = xrecallocarray(options->send_env,
+                   onum_send_env, options->num_send_env,
+                   sizeof(*options->send_env));
+       }
 }
 
 /*