Skip to content

Commit 1998a16

Browse files
committed
fix rfc1929 user/pass auth subnegotation response version field
the version field is repurposed here to mean "version of the subnegotation", which in this case is 1, not 5, as intuitively expected. interestingly, most socks5 clients don't check the version respond, rather only the success field.
1 parent 0ad6d17 commit 1998a16

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sockssrv.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ static void add_auth_ip(struct client*client) {
214214
pthread_mutex_unlock(&auth_ips_mutex);
215215
}
216216

217-
static void send_auth_response(int fd, enum authmethod meth) {
217+
static void send_auth_response(int fd, int version, enum authmethod meth) {
218218
unsigned char buf[2];
219-
buf[0] = 5;
219+
buf[0] = version;
220220
buf[1] = meth;
221221
write(fd, buf, 2);
222222
}
@@ -293,12 +293,12 @@ static void* clientthread(void *data) {
293293
am = check_auth_method(buf, n, &t->client);
294294
if(am == AM_NO_AUTH) t->state = SS_3_AUTHED;
295295
else if (am == AM_USERNAME) t->state = SS_2_NEED_AUTH;
296-
send_auth_response(t->client.fd, am);
296+
send_auth_response(t->client.fd, 5, am);
297297
if(am == AM_INVALID) goto breakloop;
298298
break;
299299
case SS_2_NEED_AUTH:
300300
ret = check_credentials(buf, n);
301-
send_auth_response(t->client.fd, ret);
301+
send_auth_response(t->client.fd, 1, ret);
302302
if(ret != EC_SUCCESS)
303303
goto breakloop;
304304
t->state = SS_3_AUTHED;

0 commit comments

Comments
 (0)