wuxx / icesugar

iCESugar FPGA Board (base on iCE40UP5k)
350 stars 96 forks source link

icesprog: avoid crashes due to unsupported options #16

Closed umarcor closed 3 years ago

umarcor commented 3 years ago

Adding {NULL, 0, NULL, 0}, as the last long option avoids crashes when non-supported long options are provided.

Without this patch:

# ./icesprog.exe --version
Segmentation fault

With this patch:

# ./icesprog.exe --version
icesprog.exe: unknown option -- version
usage: icesprog.exe [OPTION] [FILE]    
             -w | --write                   write spi-flash
             -r | --read                    read  spi-flash
             -e | --erase                   erase spi-flash
             -p | --probe                   probe spi-flash
             -o | --offset                  spi-flash offset
             -l | --len                     len of write/read
             -h | --help                    display help info

             -- version 1.0 --