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 leak in sftp-server.c process_read()#363

Closed
wants to merge 1 commit into from

Conversation

jamesr
Copy link

@jamesr jamesr commented Nov 30, 2022

process_read() has a static local u_char* buf that can grow using realloc. When growing, the function was allocating a new buffer with realloc(NULL, ...) aka malloc(...) and assigning the result into buf. This leaks if the buffer is allocated more that once. This changes the growth path to call realloc(buf, ...) to reuse or free the old buffer as needed.

process_read() has a static local u_char* buf that can grow using realloc. When growing, the function was allocating a new buffer with realloc(NULL, ...) aka malloc(...) and assigning the result into buf. This leaks if the buffer is allocated more that once. This changes the growth path to call realloc(buf, ...) to reuse or free the old buffer as needed.
@djmdjm
Copy link
Contributor

djmdjm commented Mar 7, 2023

Thanks, this has been committed as 3f9231c

@djmdjm djmdjm closed this Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants