[PATCH] libc: add missing lock initialization in vswprintf

Khem Raj raj.khem at gmail.com
Tue Jun 28 23:08:13 UTC 2011


On Thu, Jun 16, 2011 at 6:14 PM,  <maksim.rayskiy at gmail.com> wrote:
> From: Maksim Rayskiy <mrayskiy at broadcom.com>
>
> Unlike vsnprintf, vswprintf does not properly initialize locking
> elements of FILE structure, which in some unfortunate cases can result
> in lockups in _vfwprintf_internal.
> Interesting, the initialization code was removed in
> 2a915734a32c5aec9a6a76c13bcb074d30e64171 at the same time as it was added
> to vsnprintf.
>

yes this seems ok to me. I will wait for Denis's response.

> Signed-off-by: Maksim Rayskiy <mrayskiy at broadcom.com>
> ---
>  libc/stdio/vswprintf.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/libc/stdio/vswprintf.c b/libc/stdio/vswprintf.c
> index e509216..2195248 100644
> --- a/libc/stdio/vswprintf.c
> +++ b/libc/stdio/vswprintf.c
> @@ -39,6 +39,11 @@ int vswprintf(wchar_t *__restrict buf, size_t size,
>        __INIT_MBSTATE(&(f.__state));
>  #endif /* __STDIO_MBSTATE */
>
> +#ifdef __UCLIBC_HAS_THREADS__
> +       f.__user_locking = 1;           /* Set user locking. */
> +       STDIO_INIT_MUTEX(f.__lock);
> +#endif /* __UCLIBC_HAS_THREADS__ */
> +
>        f.__nextopen = NULL;
>
>        if (size > ((SIZE_MAX - (size_t) buf)/sizeof(wchar_t))) {
> --
> 1.7.4.1
>
>
> _______________________________________________
> uClibc mailing list
> uClibc at uclibc.org
> http://lists.busybox.net/mailman/listinfo/uclibc
>


More information about the uClibc mailing list