falconindy / expac

alpm data extraction utility
91 stars 15 forks source link

parse_options: return -1 on invalid size unit #26

Closed andrewgregory closed 8 years ago

andrewgregory commented 8 years ago

parse_options immediately exits on an invalid size unit, preventing it from setting opt_format or updating argc and argv. main only checks for a return less than 0 to determine failure, causing it to continue without a format and treating all arguments, including options, as target packages. If one of the arguments happens to match an available package, such as "expac" in argv[0], expac will attempt to print it with a NULL format, causing a segfault.