public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Increase judgment on buf.
@ 2023-05-19  3:57 Peng Fan
  2023-05-19 11:48 ` Adhemerval Zanella Netto
  0 siblings, 1 reply; 9+ messages in thread
From: Peng Fan @ 2023-05-19  3:57 UTC (permalink / raw)
  To: libc-alpha; +Cc: Xi Ruoyao

When buf is empty, if it is not checked, the subsequent assignment
operation will trigger a page fault. This is unnecessary.

Signed-off-by: lixing <lixing@loongson.cn>
Signed-off-by: Peng Fan <fanpeng@loongson.cn>
---
 sysdeps/unix/sysv/linux/fstatat64.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/linux/fstatat64.c
index 3509d3ca6d..b635a8299a 100644
--- a/sysdeps/unix/sysv/linux/fstatat64.c
+++ b/sysdeps/unix/sysv/linux/fstatat64.c
@@ -52,9 +52,13 @@ fstatat64_time64_statx (int fd, const char *file, struct __stat64_t64 *buf,
 {
   /* 32-bit kABI with default 64-bit time_t, e.g. arc, riscv32.   Also
      64-bit time_t support is done through statx syscall.  */
-  struct statx tmp;
+  struct statx tmp, *ptr;
+  if (buf)
+	ptr = &tmp;
+  else
+	ptr = NULL;
   int r = INTERNAL_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT | flag,
-				 STATX_BASIC_STATS, &tmp);
+				 STATX_BASIC_STATS, ptr);
   if (r != 0)
     return r;
 
-- 
2.33.0


^ permalink raw reply	[flat|nested] 9+ messages in thread
[parent not found: <lxnjka-9sevacf455zj-1fthj246gvr4-712jsi8w59t4969pqyxmxkaq-l3n4z6dp0ybpuvpiuudtnfot-dl7onwkii2tq8gtprte6cu4fgip6f-ikuh33-a5p9ixcl44cx2h7mimcgl3xt-13bjom.1684553069255@email.android.com>]

end of thread, other threads:[~2023-05-21  9:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-19  3:57 [PATCH] Increase judgment on buf Peng Fan
2023-05-19 11:48 ` Adhemerval Zanella Netto
2023-05-19 11:55   ` Carlos O'Donell
2023-05-20  0:29     ` lixing
     [not found] <lxnjka-9sevacf455zj-1fthj246gvr4-712jsi8w59t4969pqyxmxkaq-l3n4z6dp0ybpuvpiuudtnfot-dl7onwkii2tq8gtprte6cu4fgip6f-ikuh33-a5p9ixcl44cx2h7mimcgl3xt-13bjom.1684553069255@email.android.com>
2023-05-20 10:19 ` Xi Ruoyao
2023-05-21  8:19   ` Paul Eggert
2023-05-21  8:27     ` Andreas Schwab
2023-05-21  8:44       ` Paul Eggert
2023-05-21  9:05         ` Andreas Schwab

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).