summaryrefslogtreecommitdiff
path: root/packet.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2017-06-24 06:38:11 +0000
committerDamien Miller <djm@mindrot.org>2017-06-24 16:56:11 +1000
commit33f86265d7e8a0e88d3a81745d746efbdd397370 (patch)
tree7f659a05e6d5b9eed131ba8e1955c8fe2a319ad1 /packet.c
parent8f574959272ac7fe9239c4f5d10fd913f8920ab0 (diff)
upstream commit
don't pass pointer to struct sshcipher between privsep processes, just redo the lookup in each using the already-passed cipher name. bz#2704 based on patch from Brooks Davis; ok markus dtucker Upstream-ID: 2eab434c09bdf549dafd7da3e32a0d2d540adbe0
Diffstat (limited to 'packet.c')
-rw-r--r--packet.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/packet.c b/packet.c
index ea78de3a6..9458ffdb2 100644
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: packet.c,v 1.261 2017/06/09 04:40:04 dtucker Exp $ */ 1/* $OpenBSD: packet.c,v 1.262 2017/06/24 06:38:11 djm 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
@@ -2222,9 +2222,7 @@ newkeys_to_blob(struct sshbuf *m, struct ssh *ssh, int mode)
2222 return r; 2222 return r;
2223 if ((b = sshbuf_new()) == NULL) 2223 if ((b = sshbuf_new()) == NULL)
2224 return SSH_ERR_ALLOC_FAIL; 2224 return SSH_ERR_ALLOC_FAIL;
2225 /* The cipher struct is constant and shared, you export pointer */
2226 if ((r = sshbuf_put_cstring(b, enc->name)) != 0 || 2225 if ((r = sshbuf_put_cstring(b, enc->name)) != 0 ||
2227 (r = sshbuf_put(b, &enc->cipher, sizeof(enc->cipher))) != 0 ||
2228 (r = sshbuf_put_u32(b, enc->enabled)) != 0 || 2226 (r = sshbuf_put_u32(b, enc->enabled)) != 0 ||
2229 (r = sshbuf_put_u32(b, enc->block_size)) != 0 || 2227 (r = sshbuf_put_u32(b, enc->block_size)) != 0 ||
2230 (r = sshbuf_put_string(b, enc->key, enc->key_len)) != 0 || 2228 (r = sshbuf_put_string(b, enc->key, enc->key_len)) != 0 ||
@@ -2298,12 +2296,15 @@ newkeys_from_blob(struct sshbuf *m, struct ssh *ssh, int mode)
2298 comp = &newkey->comp; 2296 comp = &newkey->comp;
2299 2297
2300 if ((r = sshbuf_get_cstring(b, &enc->name, NULL)) != 0 || 2298 if ((r = sshbuf_get_cstring(b, &enc->name, NULL)) != 0 ||
2301 (r = sshbuf_get(b, &enc->cipher, sizeof(enc->cipher))) != 0 ||
2302 (r = sshbuf_get_u32(b, (u_int *)&enc->enabled)) != 0 || 2299 (r = sshbuf_get_u32(b, (u_int *)&enc->enabled)) != 0 ||
2303 (r = sshbuf_get_u32(b, &enc->block_size)) != 0 || 2300 (r = sshbuf_get_u32(b, &enc->block_size)) != 0 ||
2304 (r = sshbuf_get_string(b, &enc->key, &keylen)) != 0 || 2301 (r = sshbuf_get_string(b, &enc->key, &keylen)) != 0 ||
2305 (r = sshbuf_get_string(b, &enc->iv, &ivlen)) != 0) 2302 (r = sshbuf_get_string(b, &enc->iv, &ivlen)) != 0)
2306 goto out; 2303 goto out;
2304 if ((enc->cipher = cipher_by_name(enc->name)) == NULL) {
2305 r = SSH_ERR_INVALID_FORMAT;
2306 goto out;
2307 }
2307 if (cipher_authlen(enc->cipher) == 0) { 2308 if (cipher_authlen(enc->cipher) == 0) {
2308 if ((r = sshbuf_get_cstring(b, &mac->name, NULL)) != 0) 2309 if ((r = sshbuf_get_cstring(b, &mac->name, NULL)) != 0)
2309 goto out; 2310 goto out;
@@ -2321,11 +2322,6 @@ newkeys_from_blob(struct sshbuf *m, struct ssh *ssh, int mode)
2321 if ((r = sshbuf_get_u32(b, &comp->type)) != 0 || 2322 if ((r = sshbuf_get_u32(b, &comp->type)) != 0 ||
2322 (r = sshbuf_get_cstring(b, &comp->name, NULL)) != 0) 2323 (r = sshbuf_get_cstring(b, &comp->name, NULL)) != 0)
2323 goto out; 2324 goto out;
2324 if (enc->name == NULL ||
2325 cipher_by_name(enc->name) != enc->cipher) {
2326 r = SSH_ERR_INVALID_FORMAT;
2327 goto out;
2328 }
2329 if (sshbuf_len(b) != 0) { 2325 if (sshbuf_len(b) != 0) {
2330 r = SSH_ERR_INVALID_FORMAT; 2326 r = SSH_ERR_INVALID_FORMAT;
2331 goto out; 2327 goto out;