summaryrefslogtreecommitdiff
path: root/channels.c
diff options
context:
space:
mode:
Diffstat (limited to 'channels.c')
-rw-r--r--channels.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/channels.c b/channels.c
index d118d8ff7..111a2cfa4 100644
--- a/channels.c
+++ b/channels.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: channels.c,v 1.363 2017/05/30 14:23:52 markus Exp $ */ 1/* $OpenBSD: channels.c,v 1.364 2017/05/31 00:43:04 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
@@ -1075,9 +1075,11 @@ channel_decode_socks4(Channel *c, fd_set *readset, fd_set *writeset)
1075 buffer_get(&c->input, (char *)&s4_req.dest_addr, 4); 1075 buffer_get(&c->input, (char *)&s4_req.dest_addr, 4);
1076 have = buffer_len(&c->input); 1076 have = buffer_len(&c->input);
1077 p = (char *)buffer_ptr(&c->input); 1077 p = (char *)buffer_ptr(&c->input);
1078 if (memchr(p, '\0', have) == NULL) 1078 if (memchr(p, '\0', have) == NULL) {
1079 fatal("channel %d: decode socks4: user not nul terminated", 1079 error("channel %d: decode socks4: user not nul terminated",
1080 c->self); 1080 c->self);
1081 return -1;
1082 }
1081 len = strlen(p); 1083 len = strlen(p);
1082 debug2("channel %d: decode socks4: user %s/%d", c->self, p, len); 1084 debug2("channel %d: decode socks4: user %s/%d", c->self, p, len);
1083 len++; /* trailing '\0' */ 1085 len++; /* trailing '\0' */
@@ -1095,13 +1097,15 @@ channel_decode_socks4(Channel *c, fd_set *readset, fd_set *writeset)
1095 } else { /* SOCKS4A: two strings */ 1097 } else { /* SOCKS4A: two strings */
1096 have = buffer_len(&c->input); 1098 have = buffer_len(&c->input);
1097 p = (char *)buffer_ptr(&c->input); 1099 p = (char *)buffer_ptr(&c->input);
1100 if (memchr(p, '\0', have) == NULL) {
1101 error("channel %d: decode socks4a: host not nul "
1102 "terminated", c->self);
1103 return -1;
1104 }
1098 len = strlen(p); 1105 len = strlen(p);
1099 debug2("channel %d: decode socks4a: host %s/%d", 1106 debug2("channel %d: decode socks4a: host %s/%d",
1100 c->self, p, len); 1107 c->self, p, len);
1101 len++; /* trailing '\0' */ 1108 len++; /* trailing '\0' */
1102 if (len > have)
1103 fatal("channel %d: decode socks4a: len %d > have %d",
1104 c->self, len, have);
1105 if (len > NI_MAXHOST) { 1109 if (len > NI_MAXHOST) {
1106 error("channel %d: hostname \"%.100s\" too long", 1110 error("channel %d: hostname \"%.100s\" too long",
1107 c->self, p); 1111 c->self, p);