fix help option not exit problem #97
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🩹 Fix: Exit immediately after showing help (
-hor--help)🐛 Problem
When running:
The program prints help but continues execution, which leads to:
./yersinia -h cdp ۲�۲�� �۰����۲� ۲�����۰�۲� �����۱��۲������ ����۱�����۲����� ����۱������۰����� Yersinia... �����۲�������۰��۲�� ۲���۱���������۰���۲�� The Black Death for nowadays networks ������۱���������۰������ ��۰���۱�����������۰��۲� by Slay & tomac ۲�۲��۱������������۲����� ��۲�۱�������������۰���� http://www.yersinia.net ۲����۱�������������۲۲ yersinia@yersinia.net ۲�����۱����������۲��� �۲����۱�������۲�۲� �۲�۰������۱�۰���� Prune your MSTP, RSTP, STP trees!!!! ��۰���������۲� � Usage: yersinia [-hVGIDd] [-l logfile] [-c conffile] protocol [protocol_options] -V Program version. -h This help screen. -G Graphical mode (GTK). -I Interactive mode (ncurses). -D Daemon mode. -d Debug. -l logfile Select logfile. -c conffile Select config file. protocol One of the following: cdp, dhcp, dot1q, dot1x, dtp, hsrp, isl, mpls, stp, vtp. Try 'yersinia protocol -h' to see protocol_options help Please, see the man page for a full list of options and many examples. Send your bugs & suggestions to the Yersinia developers <yersinia@yersinia.net> ^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^X^X^Z^Z^X^H^G^K, (not exit, Ctrl^C not working)This is because
parser_initial()returned 0 even after displaying help, instead of exiting cleanly.✅ Solution
Return
-1fromparser_initial()when help is invoked to signalmain()to terminate early viaclean_exit().🔧 Patch
🧪 Tested
yersinia -hprints help and exits without error.yersinia stp -attack 0 ...) works correctly.