summaryrefslogtreecommitdiff
path: root/clientloop.c
diff options
context:
space:
mode:
authorderaadt@openbsd.org <deraadt@openbsd.org>2017-05-31 09:15:42 +0000
committerDamien Miller <djm@mindrot.org>2017-06-01 14:55:22 +1000
commit9e509d4ec97cb3d71696f1a2f1fdad254cbbce11 (patch)
tree8f33ae8fa9bcfa0d9c80d0e0f1555a814a844bc1 /clientloop.c
parentdc5dc45662773c0f7745c29cf77ae2d52723e55e (diff)
upstream commit
Switch to recallocarray() for a few operations. Both growth and shrinkage are handled safely, and there also is no need for preallocation dances. Future changes in this area will be less error prone. Review and one bug found by markus Upstream-ID: 822d664d6a5a1d10eccb23acdd53578a679d5065
Diffstat (limited to 'clientloop.c')
-rw-r--r--clientloop.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/clientloop.c b/clientloop.c
index 33d6fa908..612838376 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: clientloop.c,v 1.298 2017/05/31 07:00:13 markus Exp $ */ 1/* $OpenBSD: clientloop.c,v 1.299 2017/05/31 09:15:42 deraadt Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1812,9 +1812,9 @@ hostkeys_find(struct hostkey_foreach_line *l, void *_ctx)
1812 /* This line contained a key that not offered by the server */ 1812 /* This line contained a key that not offered by the server */
1813 debug3("%s: deprecated %s key at %s:%ld", __func__, 1813 debug3("%s: deprecated %s key at %s:%ld", __func__,
1814 sshkey_ssh_name(l->key), l->path, l->linenum); 1814 sshkey_ssh_name(l->key), l->path, l->linenum);
1815 if ((tmp = reallocarray(ctx->old_keys, ctx->nold + 1, 1815 if ((tmp = recallocarray(ctx->old_keys, ctx->nold, ctx->nold + 1,
1816 sizeof(*ctx->old_keys))) == NULL) 1816 sizeof(*ctx->old_keys))) == NULL)
1817 fatal("%s: reallocarray failed nold = %zu", 1817 fatal("%s: recallocarray failed nold = %zu",
1818 __func__, ctx->nold); 1818 __func__, ctx->nold);
1819 ctx->old_keys = tmp; 1819 ctx->old_keys = tmp;
1820 ctx->old_keys[ctx->nold++] = l->key; 1820 ctx->old_keys[ctx->nold++] = l->key;
@@ -2046,9 +2046,9 @@ client_input_hostkeys(void)
2046 } 2046 }
2047 } 2047 }
2048 /* Key is good, record it */ 2048 /* Key is good, record it */
2049 if ((tmp = reallocarray(ctx->keys, ctx->nkeys + 1, 2049 if ((tmp = recallocarray(ctx->keys, ctx->nkeys, ctx->nkeys + 1,
2050 sizeof(*ctx->keys))) == NULL) 2050 sizeof(*ctx->keys))) == NULL)
2051 fatal("%s: reallocarray failed nkeys = %zu", 2051 fatal("%s: recallocarray failed nkeys = %zu",
2052 __func__, ctx->nkeys); 2052 __func__, ctx->nkeys);
2053 ctx->keys = tmp; 2053 ctx->keys = tmp;
2054 ctx->keys[ctx->nkeys++] = key; 2054 ctx->keys[ctx->nkeys++] = key;