[PATCH rtems-libbsd] ipsec-tools: Fix copying fd_set prior to select

Christian MAUDERER christian.mauderer at embedded-brains.de
Mon May 22 07:38:24 UTC 2023


Hello,

I would like to apply this patch on 5 and 6 branches. I'll create 
tickets before applying it.

Best regards

Christian

On 2023-05-22 09:36, Christian Mauderer wrote:
> The racoon session code copies an fd_set from one variable into another
> prior to calling select. That works well for simple structures.
> 
> In libbsd we have to allocate fd_sets instead of using fixed structures
> to avoid a problem with file numbers bigger than FD_SETSIZE. The simple
> assignment didn't work in that case.
> 
> This patch makes sure that a memcpy is used instead.
> ---
>   ipsec-tools/src/racoon/session.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/ipsec-tools/src/racoon/session.c b/ipsec-tools/src/racoon/session.c
> index 7ea857ba..bd2bd316 100644
> --- a/ipsec-tools/src/racoon/session.c
> +++ b/ipsec-tools/src/racoon/session.c
> @@ -215,6 +215,8 @@ session(void)
>   #ifndef __rtems__
>   	FD_ZERO(&preset_mask);
>   #else /* __rtems__ */
> +	size_t allocated_mask_size = sizeof(fd_set) *
> +	    howmany(rtems_libio_number_iops, sizeof(fd_set) * 8);
>   	allocated_preset_mask = calloc(sizeof(fd_set),
>   	    howmany(rtems_libio_number_iops, sizeof(fd_set) * 8));
>   	if (allocated_preset_mask == NULL)
> @@ -352,7 +354,12 @@ session(void)
>   
>   		/* schedular can change select() mask, so we reset
>   		 * the working copy here */
> +#ifndef __rtems__
>   		active_mask = preset_mask;
> +#else /* __rtems__ */
> +		memcpy(allocated_active_mask, allocated_preset_mask,
> +		    allocated_mask_size);
> +#endif /* __rtems__ */
>   
>   		error = select(nfds + 1, &active_mask, NULL, NULL, timeout);
>   		if (error < 0) {

-- 
--------------------------------------------
embedded brains GmbH & Co. KG
Herr Christian MAUDERER
Dornierstr. 4
82178 Puchheim
Germany
email:  christian.mauderer at embedded-brains.de
phone:  +49-89-18 94 741 - 18
mobile: +49-176-152 206 08

Registergericht: Amtsgericht München
Registernummer: HRA 117265
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/


More information about the devel mailing list