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

Bugs report #6

Open
songxpu opened this issue Aug 20, 2023 · 3 comments
Open

Bugs report #6

songxpu opened this issue Aug 20, 2023 · 3 comments

Comments

@songxpu
Copy link

songxpu commented Aug 20, 2023

There is a small bug in server.c:173

void ftp_mkd(Command *cmd, State *state)
{
  char res[2*BSIZE+32]; 
  ...
  state->message = res;
  ...
  state->message = "550 Failed to create directory. Check path or permissions.\r\n";  // local address
  ...
  write_state(state);
}

void write_state(State *state)
{
  write(state->connection, state->message, strlen(state->message)); // bug location: read previous local address
}

ASAN
image

Reproduce

USER anonymous
PASS anonymous
MKD <filename> // filename should not be existed.
@songxpu
Copy link
Author

songxpu commented Aug 20, 2023

This type of bug which can lead to undefined behaviors, but it may not cause serious impact at this project.

@songxpu
Copy link
Author

songxpu commented Aug 21, 2023

Another bug is in server.c:51, it is because state does not initialize username after allocating memory space.

State *state = malloc(sizeof(State));
...
printf("User %s sent command: %s\r\n",(state->username==0)?"unknown":state->username,buffer); // line 51

ASAN:
image

@08183080
Copy link

how you find the bug? can you share?

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

2 participants