Skip to content
Snippets Groups Projects
  • Vladislav Shpilevoy's avatar
    90eef979
    app: handle concatenated argv name-value correctly · 90eef979
    Vladislav Shpilevoy authored
    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)
    90eef979
    History
    app: handle concatenated argv name-value correctly
    Vladislav Shpilevoy authored
    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)