Closed ehdis closed 3 years ago
strlen() is not the solution here. If strncpy() fails because the section is >= 256 characters, strlen() returns results bigger than 256 and assigning \0
to section+strlen(section)
will zero some random byte on the stack.
In fact, it looks like it should be sizeof(section)-2
if originally, this line had strlen(section)-1
. The comparison to 'options"
doesn't work because the section name is options[
.
Fixed via PR, thanks @dimkr
Since commit dc6ba81
Reverting to strlen helps: https://github.com/jvinet/knock/blob/master/src/knockd.c#L576