|
1 |
| -/* $OpenBSD: channels.c,v 1.354 2016/09/30 09:19:13 markus Exp $ */ |
| 1 | +/* $OpenBSD: channels.c,v 1.355 2016/09/30 20:24:46 djm Exp $ */ |
2 | 2 | /*
|
3 | 3 | * Author: Tatu Ylonen <[email protected]>
|
4 | 4 | * Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland
|
@@ -2472,7 +2472,8 @@ channel_proxy_downstream(Channel *downstream)
|
2472 | 2472 | char *ctype = NULL, *listen_host = NULL;
|
2473 | 2473 | u_char type;
|
2474 | 2474 | size_t have;
|
2475 |
| - int ret = -1, r, id, remote_id, listen_port, idx; |
| 2475 | + int ret = -1, r, idx; |
| 2476 | + u_int id, remote_id, listen_port; |
2476 | 2477 |
|
2477 | 2478 | /* sshbuf_dump(&downstream->input, stderr); */
|
2478 | 2479 | if ((r = sshbuf_get_string_direct(&downstream->input, &cp, &have))
|
@@ -2563,14 +2564,19 @@ channel_proxy_downstream(Channel *downstream)
|
2563 | 2564 | error("%s: parse error %s", __func__, ssh_err(r));
|
2564 | 2565 | goto out;
|
2565 | 2566 | }
|
| 2567 | + if (listen_port > 65535) { |
| 2568 | + error("%s: tcpip-forward for %s: bad port %u", |
| 2569 | + __func__, listen_host, listen_port); |
| 2570 | + goto out; |
| 2571 | + } |
2566 | 2572 | /* Record that connection to this host/port is permitted. */
|
2567 | 2573 | permitted_opens = xreallocarray(permitted_opens,
|
2568 | 2574 | num_permitted_opens + 1, sizeof(*permitted_opens));
|
2569 | 2575 | idx = num_permitted_opens++;
|
2570 | 2576 | permitted_opens[idx].host_to_connect = xstrdup("<mux>");
|
2571 | 2577 | permitted_opens[idx].port_to_connect = -1;
|
2572 | 2578 | permitted_opens[idx].listen_host = listen_host;
|
2573 |
| - permitted_opens[idx].listen_port = listen_port; |
| 2579 | + permitted_opens[idx].listen_port = (int)listen_port; |
2574 | 2580 | permitted_opens[idx].downstream = downstream;
|
2575 | 2581 | listen_host = NULL;
|
2576 | 2582 | break;
|
|
0 commit comments