public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin/main] Cygwin: gettimeofday: allow tv NULL pointer
Date: Tue, 20 Feb 2024 11:33:14 +0000 (GMT)	[thread overview]
Message-ID: <20240220113314.BC2993858D20@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=70653fd8f1db70b8776d22517fa737338eea18c7

commit 70653fd8f1db70b8776d22517fa737338eea18c7
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Tue Feb 20 12:30:34 2024 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Tue Feb 20 12:30:34 2024 +0100

    Cygwin: gettimeofday: allow tv NULL pointer
    
    Add a missing check for the struct timeval pointer being NULL.
    
    Reported-by: 109224573 <109224573@qq.com>
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/release/3.5.1 | 3 +++
 winsup/cygwin/times.cc      | 9 ++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/release/3.5.1 b/winsup/cygwin/release/3.5.1
index 96d2ad32fa79..f3983c450dd9 100644
--- a/winsup/cygwin/release/3.5.1
+++ b/winsup/cygwin/release/3.5.1
@@ -20,3 +20,6 @@ Fixes:
 - Fix the problem that VMIN and VTIME does not work at all in console.
 
 - Fix a bug that cannot handle consoles more than 32, rather than 64.
+
+- Fix gettimeofday not checking for a NULL pointer
+  Addresses: https://cygwin.com/pipermail/cygwin/2024-February/255473.html
diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index 87773934bfd7..71a7210318fa 100644
--- a/winsup/cygwin/times.cc
+++ b/winsup/cygwin/times.cc
@@ -172,10 +172,13 @@ gettimeofday (struct timeval *__restrict tv, void *__restrict tzvp)
   static bool tzflag;
   LONGLONG now = get_clock (CLOCK_REALTIME)->usecs ();
 
-  tv->tv_sec = now / USPERSEC;
-  tv->tv_usec = now % USPERSEC;
+  if (tv)
+    {
+      tv->tv_sec = now / USPERSEC;
+      tv->tv_usec = now % USPERSEC;
+    }
 
-  if (tz != NULL)
+  if (tz)
     {
       if (!tzflag)
 	{

                 reply	other threads:[~2024-02-20 11:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240220113314.BC2993858D20@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /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).