Re: [PATCH] getopt: Terminate long_options even if add_long_options is never called

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 19, 2016 at 06:35:57PM -0400, Anders Kaseorg wrote:
> v2.26-rc1~140^2 “getopt: avoid re-terminating long_option list at
> every update” forgot to terminate the long_options list in the case
> where -l/--longoptions was not specified at all, so that
> add_long_options is never called.  The resulting garbage may crash
> getopt if any long options are provided:
> 
> $ LANG=de_DE getopt -o c -- --help
> Segmentation fault (core dumped)

I have applied a little bit different solution
https://github.com/karelzak/util-linux/commit/e1164591f7927402af8d73d340e75dbfeb06a288

> +	ctl.long_options[0].name = NULL;
> +	ctl.long_options[0].has_arg = 0;
> +	ctl.long_options[0].flag = NULL;
> +	ctl.long_options[0].val = 0;

now add_longopt(ctl, NULL, 0) always terminates the array.

Please, re-test it. Thanks!

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux