public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Szabolcs Nagy <szabolcs.nagy@arm.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH 13/20] Use uintptr_t in string/tester for pointer alignment
Date: Fri, 28 Oct 2022 11:11:14 -0300	[thread overview]
Message-ID: <d4afb162-b6f7-453e-dd9c-501e6fdb84ae@linaro.org> (raw)
In-Reply-To: <84fb3b5f7c4c0ea690ac3056fb2a8d97610dd3b4.1666877952.git.szabolcs.nagy@arm.com>



On 27/10/22 12:33, Szabolcs Nagy via Libc-alpha wrote:
> The code assumed unsigned long can represent pointers.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  string/tester.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/string/tester.c b/string/tester.c
> index eed76239f5..ba948c5723 100644
> --- a/string/tester.c
> +++ b/string/tester.c
> @@ -27,6 +27,7 @@
>  #endif
>  
>  #include <errno.h>
> +#include <stdint.h>
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
> @@ -529,7 +530,7 @@ test_strlen (void)
>      char *p;
>      for (i=0; i < 0x100; i++)
>        {
> -	p = (char *) ((unsigned long int)(buf + 0xff) & ~0xff) + i;
> +	p = (char *) ((uintptr_t)(buf + 0xff) & ~0xff) + i;
>  	strcpy (p, "OK");
>  	strcpy (p+3, "BAD/WRONG");
>  	check (strlen (p) == 2, 4+i);
> @@ -554,7 +555,7 @@ test_strnlen (void)
>    char buf[4096];
>    for (int i = 0; i < 0x100; ++i)
>      {
> -      char *p = (char *) ((unsigned long int)(buf + 0xff) & ~0xff) + i;
> +      char *p = (char *) ((uintptr_t)(buf + 0xff) & ~0xff) + i;
>        strcpy (p, "OK");
>        strcpy (p + 3, "BAD/WRONG");
>        check (strnlen (p, 100) == 2, 10 + i);
> @@ -582,7 +583,7 @@ test_strchr (void)
>      char *p;
>      for (i=0; i < 0x100; i++)
>        {
> -	p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i;
> +	p = (char *) ((uintptr_t) (buf + 0xff) & ~0xff) + i;
>  	strcpy (p, "OK");
>  	strcpy (p+3, "BAD/WRONG");
>  	check (strchr (p, '/') == NULL, 9+i);
> @@ -614,7 +615,7 @@ test_strchrnul (void)
>      char *p;
>      for (i=0; i < 0x100; i++)
>        {
> -	p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i;
> +	p = (char *) ((uintptr_t) (buf + 0xff) & ~0xff) + i;
>  	strcpy (p, "OK");
>  	strcpy (p+3, "BAD/WRONG");
>  	cp = strchrnul (p, '/');
> @@ -643,7 +644,7 @@ test_rawmemchr (void)
>      char *p;
>      for (i=0; i < 0x100; i++)
>        {
> -	p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i;
> +	p = (char *) ((uintptr_t) (buf + 0xff) & ~0xff) + i;
>  	strcpy (p, "OK");
>  	strcpy (p+3, "BAD/WRONG");
>  	check (rawmemchr (p, 'R') == p+8, 6+i);
> @@ -689,7 +690,7 @@ test_strrchr (void)
>      char *p;
>      for (i=0; i < 0x100; i++)
>        {
> -	p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i;
> +	p = (char *) ((uintptr_t) (buf + 0xff) & ~0xff) + i;
>  	strcpy (p, "OK");
>  	strcpy (p+3, "BAD/WRONG");
>  	check (strrchr (p, '/') == NULL, 9+i);

  reply	other threads:[~2022-10-28 14:11 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27 15:32 [PATCH 00/20] patches from the morello port Szabolcs Nagy
2022-10-27 15:32 ` [PATCH 01/20] Fix OOB read in stdlib thousand grouping parsing [BZ #29727] Szabolcs Nagy
2022-10-27 15:38   ` Andreas Schwab
2022-10-27 15:32 ` [PATCH 02/20] scripts: Use bool in tunables initializer Szabolcs Nagy
2022-10-27 16:29   ` Florian Weimer
2022-10-27 15:32 ` [PATCH 03/20] aarch64: Don't build wordcopy Szabolcs Nagy
2022-10-27 16:59   ` Adhemerval Zanella Netto
2022-10-27 15:32 ` [PATCH 04/20] aarch64: Fix the extension header write in getcontext and swapcontext Szabolcs Nagy
2022-10-28 14:03   ` Adhemerval Zanella Netto
2022-10-27 15:32 ` [PATCH 05/20] Fix invalid pointer dereference in wcscpy_chk Szabolcs Nagy
2022-10-28  5:34   ` Florian Weimer
2022-10-27 15:32 ` [PATCH 06/20] Fix invalid pointer dereference in wcpcpy_chk Szabolcs Nagy
2022-10-28  5:45   ` Florian Weimer
2022-10-27 15:32 ` [PATCH 07/20] Use uintptr_t in fts for pointer alignment Szabolcs Nagy
2022-10-31 16:08   ` Adhemerval Zanella Netto
2022-10-27 15:32 ` [PATCH 08/20] malloc: Use uintptr_t " Szabolcs Nagy
2022-10-31 16:09   ` Adhemerval Zanella Netto
2022-10-27 15:32 ` [PATCH 09/20] malloc: Use uintptr_t in alloc_buffer Szabolcs Nagy
2022-10-27 16:15   ` Florian Weimer
2022-10-27 15:33 ` [PATCH 10/20] malloc: Fix alignment logic in obstack Szabolcs Nagy
2022-10-31 16:14   ` Adhemerval Zanella Netto
2022-11-01  9:43     ` Szabolcs Nagy
2022-11-01 13:07       ` Adhemerval Zanella Netto
2022-10-27 15:33 ` [PATCH 11/20] elf: Fix alloca size in _dl_debug_vdprintf Szabolcs Nagy
2022-10-28  5:31   ` Florian Weimer
2022-10-28 13:56   ` Adhemerval Zanella Netto
2022-10-28 14:43     ` Szabolcs Nagy
2022-10-28 14:48       ` Adhemerval Zanella Netto
2022-10-27 15:33 ` [PATCH 12/20] Fix the symbolic link of multilib dirs Szabolcs Nagy
2022-10-27 15:33 ` [PATCH 13/20] Use uintptr_t in string/tester for pointer alignment Szabolcs Nagy
2022-10-28 14:11   ` Adhemerval Zanella Netto [this message]
2022-10-27 15:33 ` [PATCH 14/20] Fix off-by-one OOB write in iconv/tst-iconv-mt Szabolcs Nagy
2022-10-28  5:39   ` Florian Weimer
2022-10-27 15:33 ` [PATCH 15/20] Fix off-by-one OOB read in elf/tst-tls20 Szabolcs Nagy
2022-10-28  5:36   ` Florian Weimer
2022-10-27 15:33 ` [PATCH 16/20] Fix malloc/tst-scratch_buffer OOB access Szabolcs Nagy
2022-10-28  5:41   ` Florian Weimer
2022-10-28 11:24     ` Szabolcs Nagy
2022-10-28 11:30       ` Florian Weimer
2022-10-28 12:23         ` Szabolcs Nagy
2022-10-28 12:27           ` Florian Weimer
2022-10-27 15:33 ` [PATCH 17/20] Fix missing NUL terminator in stdio-common/scanf13 test Szabolcs Nagy
2022-10-28  5:44   ` Florian Weimer
2022-10-27 15:33 ` [PATCH 18/20] Fix elf/tst-dlmopen-twice to support enough link namespaces Szabolcs Nagy
2022-10-27 16:24   ` Florian Weimer
2022-10-27 16:45     ` Szabolcs Nagy
2022-10-27 16:51       ` Florian Weimer
2022-10-27 16:47     ` Adhemerval Zanella Netto
2022-10-27 15:33 ` [PATCH 19/20] Fix resource/bug-ulimit1 test Szabolcs Nagy
2022-10-27 16:48   ` Adhemerval Zanella Netto
2022-10-27 15:34 ` [PATCH 20/20] Fix stdlib/test-dlclose-exit-race to not hang Szabolcs Nagy
2022-10-27 16:22   ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d4afb162-b6f7-453e-dd9c-501e6fdb84ae@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    --cc=szabolcs.nagy@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).