app: handle concatenated argv name-value correctly
The server used to crash when any option argument was passed with a value concatenated to it, like this: '-lvalue', '-evalue' instead of '-l value' and '-e value'. However this is a valid way of writing values, and it should not have crashed regardless of its validity. The bug was in usage of 'optind' global variable from getopt() function family. It is not supposed to be used for getting an option's value. It points to a next argv to parse. Next argv != value of current argv, like it was with '-lvalue' and '-evalue'. For getting a current value there is a variable 'optarg'. Closes #4775 (cherry picked from commit 29cfd564)
Showing
- src/lua/init.c 2 additions, 2 deletionssrc/lua/init.c
- src/lua/init.h 1 addition, 1 deletionsrc/lua/init.h
- src/main.cc 5 additions, 8 deletionssrc/main.cc
- test/app/gh-4775-crash-args-l-e.result 14 additions, 0 deletionstest/app/gh-4775-crash-args-l-e.result
- test/app/gh-4775-crash-args-l-e.test.lua 8 additions, 0 deletionstest/app/gh-4775-crash-args-l-e.test.lua
Loading
Please register or sign in to comment