-
Notifications
You must be signed in to change notification settings - Fork 526
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
channel: remove unused code #1345
base: master
Are you sure you want to change the base?
Conversation
@libssh2/dev-team: Any opinion on this PR? Are we safe to merge? |
I'm trying to be paranoid about innocent-looking changes because of the recent xz exploit, but this seems OK to me. The only way this could affect execution is if So potentially you could get into trouble if your Still being paranoid, maybe there's a memcpy or a memmove that overwrites that part of the I think this change is probably fine, assuming clients aren't overwriting data in |
Thanks @MichaelBuckley. Your assessment, and the original proposition are giving the impression that this may add some potential risk and/or reduce robustness, while it's not completely certain if it resolves an actual issue. For the gain of 15 lines of code and saving one member in the channel structrure, I think it's not worth taking that risk. What about adding a comment on the top of this block of code instead, that explains the situation for future readers? |
I think the risk is very, very, very small. If the client is using libssh2 correctly, there is no risk. I am only being paranoid because of the recent xz exploit. That said, you are right that the benefit is also small. 15 lines of code, 1 strict member, and a small amount of execution time. |
Nobody missed it before; why would they now?
Ref #1344.
Was going through the code and found some unused code.
https://github.com/libssh2/libssh2/blob/master/src/channel.c#L2009-L2017
if
channel->extData2_state == libssh2_NB_state_idle
when the function starts, then the first if changes it tolibssh2_NB_state_created
and then for the next if the state won't be idle anymore, and the second if won't run. If it's not idle, then nothing happens, and the state is reset to idle.Really this is the only function that uses
extData2_state
So the function becomes just
and
extData2_state
can be removed from the channel structure.Or - maybe if there is really a flush still desired, maybe the second if should use
channel->extData2_state == libssh2_NB_state_created
instead ofchannel->extData2_state == libssh2_NB_state_idle
.