[PATCH 1/2] env: use getopt_long instead of getopt32long

Marc Kewitz herderkewitz at googlemail.com
Mon Apr 7 15:38:45 UTC 2025


Quoting <https://www.gnu.org/software/libc/manual/html_node/Using-Getopt.html>
"You don’t ordinarily need to copy the optarg string, since it is a pointer into the original argv array, not into a static area that might be overwritten." I think we should be safe here.

On April 7, 2025 3:12:50 PM GMT+02:00, "Csókás Bence" <csokas.bence at prolan.hu> wrote:
>Hi,
>
>On 2025. 04. 07. 12:08, Marc Kewitz wrote:
>> +	while ((optc = getopt_long(argc, argv, short_options, long_options, NULL)) != -1) {
>> +		switch (optc)
>> +		{
>> +		case 'i':
>> +			ignore_environment = true;
>> +			break;
>> +		case 'u':
>> +			add_unset_var(optarg);
>
>Is it guaranteed that the memory pointed to by `optarg` will not change after consecutive calls to `getopt*()`? I don't see it specified either way in the man page.
>
>Bence
>
>_______________________________________________
>busybox mailing list
>busybox at busybox.net
>https://lists.busybox.net/mailman/listinfo/busybox
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20250407/3366e22e/attachment.htm>


More information about the busybox mailing list