summaryrefslogtreecommitdiff
path: root/packet.c
diff options
context:
space:
mode:
authormarkus@openbsd.org <markus@openbsd.org>2015-03-24 20:10:08 +0000
committerDamien Miller <djm@mindrot.org>2015-03-27 12:01:47 +1100
commit4daeb67181054f2a377677fac919ee8f9ed3490e (patch)
tree0d942da2c39f33f46282be8989e6963383aeffcb /packet.c
parent7d4f96f9de2a18af0d9fa75ea89a4990de0344f5 (diff)
upstream commit
don't leak 'setp' on error; noted by Nicholas Lemonias; ok djm@
Diffstat (limited to 'packet.c')
-rw-r--r--packet.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/packet.c b/packet.c
index 5e18de437..ec2cbd30e 100644
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: packet.c,v 1.209 2015/03/11 00:48:39 jsg Exp $ */ 1/* $OpenBSD: packet.c,v 1.210 2015/03/24 20:10:08 markus 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
@@ -1279,10 +1279,8 @@ ssh_packet_read_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)
1279 * Since we are blocking, ensure that all written packets have 1279 * Since we are blocking, ensure that all written packets have
1280 * been sent. 1280 * been sent.
1281 */ 1281 */
1282 if ((r = ssh_packet_write_wait(ssh)) != 0) { 1282 if ((r = ssh_packet_write_wait(ssh)) != 0)
1283 free(setp); 1283 goto out;
1284 return r;
1285 }
1286 1284
1287 /* Stay in the loop until we have received a complete packet. */ 1285 /* Stay in the loop until we have received a complete packet. */
1288 for (;;) { 1286 for (;;) {
@@ -1340,15 +1338,20 @@ ssh_packet_read_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)
1340 len = roaming_read(state->connection_in, buf, 1338 len = roaming_read(state->connection_in, buf,
1341 sizeof(buf), &cont); 1339 sizeof(buf), &cont);
1342 } while (len == 0 && cont); 1340 } while (len == 0 && cont);
1343 if (len == 0) 1341 if (len == 0) {
1344 return SSH_ERR_CONN_CLOSED; 1342 r = SSH_ERR_CONN_CLOSED;
1345 if (len < 0) 1343 goto out;
1346 return SSH_ERR_SYSTEM_ERROR; 1344 }
1345 if (len < 0) {
1346 r = SSH_ERR_SYSTEM_ERROR;
1347 goto out;
1348 }
1347 1349
1348 /* Append it to the buffer. */ 1350 /* Append it to the buffer. */
1349 if ((r = ssh_packet_process_incoming(ssh, buf, len)) != 0) 1351 if ((r = ssh_packet_process_incoming(ssh, buf, len)) != 0)
1350 return r; 1352 goto out;
1351 } 1353 }
1354 out:
1352 free(setp); 1355 free(setp);
1353 return r; 1356 return r;
1354} 1357}