-
Notifications
You must be signed in to change notification settings - Fork 143
Fix issue with double-start of clipboard monitor #121
Conversation
If a user attempts to start the clipboard monitor when it is already started then the code path that is taken results in the current clipboard monitor state pointers being lost. The net effect of this is that the existing monitor thread will never be shut down. Not a good thing! This code fixes that case so that the monitor doesn't create a new monitor thread and doesn't reset important pointers to NULL. This change also results in a "success" status being returned to the caller. This means it looks like the clipboard monitor has been started even if it was already running. I think this is acceptable and is better than an obscure error.
Test PASSED. |
{ | ||
destroy_clipboard_monitor_state(pState); | ||
if (pState != NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well, but shouldn't we set pState to NULL after freeing it too in destroy_clipboard_monitor_state()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pState
is a local variable, so no it's not necessary. Once it's freed and the function exists it's no longer in scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see what you're saying. Sorry, I misunderstood.
Potentially, and that would require the func signature changing. Could be good for the sake of being thorough!
Thanks @bcook-r7. Made an adjustment based on your suggestion. Would you mind retesting please? |
Test PASSED. |
Of course - just a sec. |
Looking good:
|
Cheers! |
Hopefully the last manual build before packaging the Linux bins into meterpreter_bins as well. This includes all of the fixes and improvements over the past month. rapid7/meterpreter#116 rapid7/meterpreter#117 rapid7/meterpreter#121 rapid7/meterpreter#124
Seems legit:
Behaving fine for me on Windoze. |
Same on the nixes
We really should sort out that channel closing issue on *nix too. Landing! |
If a user attempts to start the clipboard monitor when it is already started then the code path that is taken results in the current clipboard monitor state pointers being lost. The net effect of this is that the existing monitor thread will never be shut down. Not a good thing!
This code fixes that case so that the monitor doesn't create a new monitor thread and doesn't reset important pointers to NULL.
This change also results in a "success" status being returned to the caller. This means it looks like the clipboard monitor has been started even if it was already running. I think this is acceptable and is better than an obscure error.
@wchen-r7 reported this as an issue. Fixes #120.
Verification
clipboard_monitor_start
multiple times results in an indication of success.clipboard_monitor_start
multiple times that the user is able to successfully shut down the monitor usingclipboard_monitor_stop
.Sample run