summaryrefslogtreecommitdiff
path: root/packet.c
diff options
context:
space:
mode:
authorderaadt@openbsd.org <deraadt@openbsd.org>2016-09-12 01:22:38 +0000
committerDarren Tucker <dtucker@zip.com.au>2016-09-12 13:46:29 +1000
commit9136ec134c97a8aff2917760c03134f52945ff3c (patch)
treebfcab357e6e0f510d9b63bac43b18097e89fa58a /packet.c
parentf219fc8f03caca7ac82a38ed74bbd6432a1195e7 (diff)
upstream commit
Add MAXIMUM(), MINIMUM(), and ROUNDUP() to misc.h, then use those definitions rather than pulling <sys/param.h> and unknown namespace pollution. ok djm markus dtucker Upstream-ID: 712cafa816c9f012a61628b66b9fbd5687223fb8
Diffstat (limited to 'packet.c')
-rw-r--r--packet.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/packet.c b/packet.c
index 9ee23147e..711091da7 100644
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: packet.c,v 1.236 2016/09/06 09:22:56 markus Exp $ */ 1/* $OpenBSD: packet.c,v 1.237 2016/09/12 01:22:38 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
@@ -38,8 +38,7 @@
38 */ 38 */
39 39
40#include "includes.h" 40#include "includes.h"
41 41
42#include <sys/param.h> /* MIN roundup */
43#include <sys/types.h> 42#include <sys/types.h>
44#include "openbsd-compat/sys-queue.h" 43#include "openbsd-compat/sys-queue.h"
45#include <sys/socket.h> 44#include <sys/socket.h>
@@ -1069,7 +1068,7 @@ ssh_set_newkeys(struct ssh *ssh, int mode)
1069 else 1068 else
1070 *max_blocks = ((u_int64_t)1 << 30) / enc->block_size; 1069 *max_blocks = ((u_int64_t)1 << 30) / enc->block_size;
1071 if (state->rekey_limit) 1070 if (state->rekey_limit)
1072 *max_blocks = MIN(*max_blocks, 1071 *max_blocks = MINIMUM(*max_blocks,
1073 state->rekey_limit / enc->block_size); 1072 state->rekey_limit / enc->block_size);
1074 debug("rekey after %llu blocks", (unsigned long long)*max_blocks); 1073 debug("rekey after %llu blocks", (unsigned long long)*max_blocks);
1075 return 0; 1074 return 0;
@@ -1112,7 +1111,7 @@ ssh_packet_need_rekeying(struct ssh *ssh, u_int outbound_packet_len)
1112 return 1; 1111 return 1;
1113 1112
1114 /* Rekey after (cipher-specific) maxiumum blocks */ 1113 /* Rekey after (cipher-specific) maxiumum blocks */
1115 out_blocks = roundup(outbound_packet_len, 1114 out_blocks = ROUNDUP(outbound_packet_len,
1116 state->newkeys[MODE_OUT]->enc.block_size); 1115 state->newkeys[MODE_OUT]->enc.block_size);
1117 return (state->max_blocks_out && 1116 return (state->max_blocks_out &&
1118 (state->p_send.blocks + out_blocks > state->max_blocks_out)) || 1117 (state->p_send.blocks + out_blocks > state->max_blocks_out)) ||
@@ -1240,7 +1239,7 @@ ssh_packet_send2_wrapped(struct ssh *ssh)
1240 if (state->extra_pad) { 1239 if (state->extra_pad) {
1241 tmp = state->extra_pad; 1240 tmp = state->extra_pad;
1242 state->extra_pad = 1241 state->extra_pad =
1243 roundup(state->extra_pad, block_size); 1242 ROUNDUP(state->extra_pad, block_size);
1244 /* check if roundup overflowed */ 1243 /* check if roundup overflowed */
1245 if (state->extra_pad < tmp) 1244 if (state->extra_pad < tmp)
1246 return SSH_ERR_INVALID_ARGUMENT; 1245 return SSH_ERR_INVALID_ARGUMENT;