diff options
author | dtucker@openbsd.org@openbsd.org <dtucker@openbsd.org@openbsd.org> | 2017-11-25 06:46:22 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2017-11-28 12:01:49 +1100 |
commit | 5db6fbf1438b108e5df3e79a1b4de544373bc2d4 (patch) | |
tree | 95f5df8248cca30df3ab00e70e80d28410be760c /packet.c | |
parent | 2d638e986085bdf1a40310ed6e2307463db96ea0 (diff) |
upstream commit
Add monotime_ts and monotime_tv that return monotonic
timespec and timeval respectively. Replace calls to gettimeofday() in packet
timing with monotime_tv so that the callers will work over a clock step.
Should prevent integer overflow during clock steps reported by wangle6 at
huawei.com. "I like" markus@
OpenBSD-Commit-ID: 74d684264814ff806f197948b87aa732cb1b0b8a
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: packet.c,v 1.266 2017/10/25 00:17:08 djm Exp $ */ | 1 | /* $OpenBSD: packet.c,v 1.267 2017/11/25 06:46:22 dtucker 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 |
@@ -1332,7 +1332,7 @@ ssh_packet_read_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p) | |||
1332 | for (;;) { | 1332 | for (;;) { |
1333 | if (state->packet_timeout_ms != -1) { | 1333 | if (state->packet_timeout_ms != -1) { |
1334 | ms_to_timeval(&timeout, ms_remain); | 1334 | ms_to_timeval(&timeout, ms_remain); |
1335 | gettimeofday(&start, NULL); | 1335 | monotime_tv(&start); |
1336 | } | 1336 | } |
1337 | if ((r = select(state->connection_in + 1, setp, | 1337 | if ((r = select(state->connection_in + 1, setp, |
1338 | NULL, NULL, timeoutp)) >= 0) | 1338 | NULL, NULL, timeoutp)) >= 0) |
@@ -1959,7 +1959,7 @@ ssh_packet_write_wait(struct ssh *ssh) | |||
1959 | for (;;) { | 1959 | for (;;) { |
1960 | if (state->packet_timeout_ms != -1) { | 1960 | if (state->packet_timeout_ms != -1) { |
1961 | ms_to_timeval(&timeout, ms_remain); | 1961 | ms_to_timeval(&timeout, ms_remain); |
1962 | gettimeofday(&start, NULL); | 1962 | monotime_tv(&start); |
1963 | } | 1963 | } |
1964 | if ((ret = select(state->connection_out + 1, | 1964 | if ((ret = select(state->connection_out + 1, |
1965 | NULL, setp, NULL, timeoutp)) >= 0) | 1965 | NULL, setp, NULL, timeoutp)) >= 0) |