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

Crash due to missing logw() argument #84

Closed
vanrein opened this issue Mar 15, 2022 · 3 comments
Closed

Crash due to missing logw() argument #84

vanrein opened this issue Mar 15, 2022 · 3 comments

Comments

@vanrein
Copy link

vanrein commented Mar 15, 2022

I triggered a simple oversight in master, in src/conn.c it says

#ifdef DEBUG
    logw(5, "conn[%s]: request data len changed from %d to %d",
         MB_FRAME(conn->buf, MB_LENGTH_L), len);
#endif

There should be 3 arguments after the logw() format string, not 2. The crashing stopped when I changed [%s] to [%%s].

I may have been doing something wrong —I am starting a project and am may be sending invalid packets— but your dæmon might want to stick around to tell me off :-)

@dgoo2308
Copy link
Contributor

dgoo2308 commented Apr 6, 2022

@vanrein

please try with adding conn->remote_addr in the logw of conn_fix_request_header_len

void
conn_fix_request_header_len(conn_t *conn, unsigned char len)
{
  if (MB_FRAME(conn->buf, MB_LENGTH_L) != len)
  {
#ifdef DEBUG
    logw(5, "conn[%s]: request data len changed from %d to %d",
         conn->remote_addr,MB_FRAME(conn->buf, MB_LENGTH_L), len);
#endif
    MB_FRAME(conn->buf, MB_LENGTH_L) = len;
  }
}

@vanrein
Copy link
Author

vanrein commented Apr 6, 2022

That fixes the problem, indeed. Thanks.

To test, I reconstructed the situation because it was originally my bug triggering yours; my bug has since been fixed. So I added an else branch printing to also produce this error, I saw that crash in the same manner, and then applied your fix to see the crash gone.

@3cky
Copy link
Owner

3cky commented Apr 6, 2022

Thanks, guys. Indeed conn->remote_addr argument was missing. Will fix it.

@3cky 3cky closed this as completed in 06ccb29 Apr 6, 2022
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

No branches or pull requests

3 participants