Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix post_msg implementation bug #166

Closed
wants to merge 1 commit into from
Closed

Conversation

grandnew
Copy link

@grandnew grandnew commented Jan 7, 2022

I think the error handling code of post_msg is wrongly implemented due to coding typo. The EPIPE should be also considered and then return -1, just like PPTP_write:

static int pptp_write(struct triton_md_handler_t *h)
{
struct pptp_conn_t *conn = container_of(h, typeof(*conn), hnd);
int n;
while (1) {
n = write(h->fd, conn->out_buf+conn->out_pos, conn->out_size-conn->out_pos);
if (n < 0) {
if (errno == EINTR)
continue;
if (errno == EAGAIN)
n = 0;
else {
if (errno != EPIPE) {
if (conf_verbose)
log_ppp_info2("pptp: post_msg: %s\n", strerror(errno));
}
disconnect(conn);
return 1;
}
}
conn->out_pos += n;
if (conn->out_pos == conn->out_size) {
conn->out_pos = 0;
conn->out_size = 0;
triton_md_disable_handler(h, MD_MODE_WRITE);
return 0;
}
}
}

This pr fixes #158.

I think the error handling code of `post_msg` is wrongly implemented due to coding typo. The `EPIPE` should be also considered and then return -1, just like `PPTP_write`:
https://github.com/xebd/accel-ppp/blob/1b8711cf75a7c278d99840112bc7a396398e0205/accel-pppd/ctrl/pptp/pptp.c#L539-L570

This pr fixes xebd#158.
@Neustradamus
Copy link

Dear @grandnew,

Can you open a PR at "good" place:

Thanks in advance.

@grandnew
Copy link
Author

@Neustradamus Sure. Please check: accel-ppp/accel-ppp#216

@grandnew grandnew closed this Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Abnormal packet sequence can cause stack-buffer-underflow
2 participants