Skip to content

Commit

Permalink
Fix proxy v1 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Oct 10, 2024
1 parent 0ccec68 commit 0665ee0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/proxy_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@ static int proxy_v1__decode(struct mosquitto *context)
return MOSQ_ERR_INVAL;
}

context->proxy.buf[context->proxy.pos-1] = '\0';
context->proxy.buf[context->proxy.pos-2] = '\0';
saddr_s = strtok_r((char *)&context->proxy.buf[sizeof(signature4)], " ", &saveptr);
daddr_s = strtok_r(NULL, " ", &saveptr);
sport_s = strtok_r(NULL, " ", &saveptr);
dport_s = strtok_r(NULL, " ", &saveptr);

if(!saddr_s || !daddr_s || !sport_s || !dport_s || !saveptr || saveptr[0] != '\0'){

if(!saddr_s || !daddr_s || !sport_s || !dport_s || (saveptr && strlen(saveptr) > 0)){
log__printf(NULL, MOSQ_LOG_NOTICE, "Connection rejected, corrupt PROXY header.");
proxy_cleanup(context);
return MOSQ_ERR_INVAL;
Expand Down

0 comments on commit 0665ee0

Please sign in to comment.