public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v1] stdlib: Fixup mbstowcs NULL __dst handling.
@ 2022-06-22 23:34 Noah Goldstein
  2022-06-23  5:46 ` Siddhesh Poyarekar
  0 siblings, 1 reply; 3+ messages in thread
From: Noah Goldstein @ 2022-06-22 23:34 UTC (permalink / raw)
  To: libc-alpha

commit 464d189b9622932a75302290625de84931656ec0 (origin/master, origin/HEAD)
Author: Noah Goldstein <goldstein.w.n@gmail.com>
Date:   Wed Jun 22 08:24:21 2022 -0700

    stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265]

Incorrectly called `__mbstowcs_chk` in the NULL __dst case which is
incorrect as in the NULL __dst case we are explicitly skipping
the objsize checks.

As well, remove the `__always_inline` attribute which exists in
`__fortify_function`.
---
 stdlib/bits/stdlib.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h
index d9c2d822a5..de1c3b20f0 100644
--- a/stdlib/bits/stdlib.h
+++ b/stdlib/bits/stdlib.h
@@ -96,10 +96,10 @@ extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
 			      const char *__restrict __src,
 			      size_t __len, size_t __dstlen) __THROW
     __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
-extern size_t __REDIRECT_NTH (__mbstowcs_chk_nulldst,
+extern size_t __REDIRECT_NTH (__mbstowcs_nulldst,
 			      (wchar_t *__restrict __dst,
 			       const char *__restrict __src,
-			       size_t __len), mbstowcs_chk)
+			       size_t __len), mbstowcs)
     __attr_access ((__read_only__, 2));
 extern size_t __REDIRECT_NTH (__mbstowcs_alias,
 			      (wchar_t *__restrict __dst,
@@ -113,12 +113,12 @@ extern size_t __REDIRECT_NTH (__mbstowcs_chk_warn,
      __warnattr ("mbstowcs called with dst buffer smaller than len "
 		 "* sizeof (wchar_t)");
 
-__always_inline __fortify_function size_t
+__fortify_function size_t
 __NTH (mbstowcs (wchar_t *__restrict __dst, const char *__restrict __src,
 		 size_t __len))
 {
   if (__builtin_constant_p (__dst == NULL) && __dst == NULL)
-    return __mbstowcs_chk_nulldst (__dst, __src, __len);
+    return __mbstowcs_nulldst (__dst, __src, __len);
   else
     return __glibc_fortify_n (mbstowcs, __len, sizeof (wchar_t),
 			      __glibc_objsize (__dst), __dst, __src, __len);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] stdlib: Fixup mbstowcs NULL __dst handling.
  2022-06-22 23:34 [PATCH v1] stdlib: Fixup mbstowcs NULL __dst handling Noah Goldstein
@ 2022-06-23  5:46 ` Siddhesh Poyarekar
  2022-06-23 14:26   ` Siddhesh Poyarekar
  0 siblings, 1 reply; 3+ messages in thread
From: Siddhesh Poyarekar @ 2022-06-23  5:46 UTC (permalink / raw)
  To: Noah Goldstein, libc-alpha

On 23/06/2022 05:04, Noah Goldstein via Libc-alpha wrote:
> commit 464d189b9622932a75302290625de84931656ec0 (origin/master, origin/HEAD)
> Author: Noah Goldstein <goldstein.w.n@gmail.com>
> Date:   Wed Jun 22 08:24:21 2022 -0700
> 
>      stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265]
> 
> Incorrectly called `__mbstowcs_chk` in the NULL __dst case which is
> incorrect as in the NULL __dst case we are explicitly skipping
> the objsize checks.
> 
> As well, remove the `__always_inline` attribute which exists in
> `__fortify_function`.
> ---
>   stdlib/bits/stdlib.h | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)

LGTM.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

> 
> diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h
> index d9c2d822a5..de1c3b20f0 100644
> --- a/stdlib/bits/stdlib.h
> +++ b/stdlib/bits/stdlib.h
> @@ -96,10 +96,10 @@ extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
>   			      const char *__restrict __src,
>   			      size_t __len, size_t __dstlen) __THROW
>       __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
> -extern size_t __REDIRECT_NTH (__mbstowcs_chk_nulldst,
> +extern size_t __REDIRECT_NTH (__mbstowcs_nulldst,
>   			      (wchar_t *__restrict __dst,
>   			       const char *__restrict __src,
> -			       size_t __len), mbstowcs_chk)
> +			       size_t __len), mbstowcs)
>       __attr_access ((__read_only__, 2));
>   extern size_t __REDIRECT_NTH (__mbstowcs_alias,
>   			      (wchar_t *__restrict __dst,
> @@ -113,12 +113,12 @@ extern size_t __REDIRECT_NTH (__mbstowcs_chk_warn,
>        __warnattr ("mbstowcs called with dst buffer smaller than len "
>   		 "* sizeof (wchar_t)");
>   
> -__always_inline __fortify_function size_t
> +__fortify_function size_t
>   __NTH (mbstowcs (wchar_t *__restrict __dst, const char *__restrict __src,
>   		 size_t __len))
>   {
>     if (__builtin_constant_p (__dst == NULL) && __dst == NULL)
> -    return __mbstowcs_chk_nulldst (__dst, __src, __len);
> +    return __mbstowcs_nulldst (__dst, __src, __len);
>     else
>       return __glibc_fortify_n (mbstowcs, __len, sizeof (wchar_t),
>   			      __glibc_objsize (__dst), __dst, __src, __len);


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] stdlib: Fixup mbstowcs NULL __dst handling.
  2022-06-23  5:46 ` Siddhesh Poyarekar
@ 2022-06-23 14:26   ` Siddhesh Poyarekar
  0 siblings, 0 replies; 3+ messages in thread
From: Siddhesh Poyarekar @ 2022-06-23 14:26 UTC (permalink / raw)
  To: Noah Goldstein, libc-alpha

On 23/06/2022 11:16, Siddhesh Poyarekar wrote:
> On 23/06/2022 05:04, Noah Goldstein via Libc-alpha wrote:
>> commit 464d189b9622932a75302290625de84931656ec0 (origin/master, 
>> origin/HEAD)
>> Author: Noah Goldstein <goldstein.w.n@gmail.com>
>> Date:   Wed Jun 22 08:24:21 2022 -0700
>>
>>      stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265]
>>
>> Incorrectly called `__mbstowcs_chk` in the NULL __dst case which is
>> incorrect as in the NULL __dst case we are explicitly skipping
>> the objsize checks.
>>
>> As well, remove the `__always_inline` attribute which exists in
>> `__fortify_function`.
>> ---
>>   stdlib/bits/stdlib.h | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> LGTM.
> 
> Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

Please add a reference to bz #29279 in the commit log when you push this.

Sid

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-23 14:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-22 23:34 [PATCH v1] stdlib: Fixup mbstowcs NULL __dst handling Noah Goldstein
2022-06-23  5:46 ` Siddhesh Poyarekar
2022-06-23 14:26   ` Siddhesh Poyarekar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).