public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>,
	Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH v2 2/2] linux: Fix ancillary 64-bit time timestamp conversion (BZ #28349, BZ #28350)
Date: Fri, 10 Dec 2021 09:47:03 -0300	[thread overview]
Message-ID: <32567bed-9014-3db5-371a-56d4a8420966@linaro.org> (raw)
In-Reply-To: <878rwsbrri.fsf@oldenburg.str.redhat.com>



On 10/12/2021 08:53, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
> 
>> diff --git a/sysdeps/unix/sysv/linux/convert_scm_timestamps.c b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
>> index 00c934c413..5ee930035b 100644
>> --- a/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
>> +++ b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
>> @@ -54,26 +54,26 @@ __convert_scm_timestamps (struct msghdr *msg, socklen_t msgsize)
>>         cmsg != NULL;
>>         cmsg = CMSG_NXTHDR (msg, cmsg))
>>      {
>> +      if (cmsg->cmsg_level == SOL_SOCKET)
>>  	{
>> +	  switch (cmsg->cmsg_type)
>> +	    {
>> +	    case COMPAT_SO_TIMESTAMP_OLD:
>> +	      if (type != 0)
>> +		break;
>> +	      type = COMPAT_SO_TIMESTAMP_NEW;
>> +	      goto common;
>> +
>> +	    case COMPAT_SO_TIMESTAMPNS_OLD:
>> +	      type = COMPAT_SO_TIMESTAMPNS_NEW;
>> +
>> +	    /* fallthrough  */
>> +	    common:
>> +	      memcpy (tmp, CMSG_DATA (cmsg), sizeof (tmp));
>> +	      tvts[0] = tmp[0];
>> +	      tvts[1] = tmp[1];
>> +	      break;
>> +	    }
>>  	}
>>  
>>        last = cmsg;
>        }
>    
>      if (last == NULL || type == 0)
>        return;
>    
>      if (CMSG_SPACE (sizeof tvts) > msgsize - msg->msg_controllen)
>        {
>          msg->msg_flags |= MSG_CTRUNC;
>          return;
>>      }
>>
>>    msg->msg_controllen += CMSG_SPACE (sizeof tvts);
>> +  cmsg = CMSG_NXTHDR (msg, last);
>>    if (cmsg == NULL)
>>      return;
>>    cmsg->cmsg_level = SOL_SOCKET;
> 
> How can cmsg be NULL at the final if?  We always iterate until we have
> cmsg == NULL, so CMSG_NXTHDR (msg, last) should be NULL?

Indeed I think it should be safe to drop the check, we already check if before
with CMSG_SPACE and return MSG_CTRUNC if this is no extra space (which will
make CMSG_NXTHDR return NULL).

Are you ok with this change?

  reply	other threads:[~2021-12-10 12:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-29 14:06 [PATCH v2 1/2] support: Add support_socket_so_timestamp_time64 Adhemerval Zanella
2021-09-29 14:06 ` [PATCH v2 2/2] linux: Fix ancillary 64-bit time timestamp conversion (BZ #28349, BZ #28350) Adhemerval Zanella
2021-10-08 11:58   ` Adhemerval Zanella
2021-10-20 12:08     ` Adhemerval Zanella
2021-11-08 18:30       ` Adhemerval Zanella
2021-12-10 11:03         ` Adhemerval Zanella
2021-12-10 11:53   ` Florian Weimer
2021-12-10 12:47     ` Adhemerval Zanella [this message]
2021-12-10 12:56       ` Florian Weimer
2021-12-10 12:59         ` Florian Weimer
2021-12-10 13:13           ` Adhemerval Zanella
2021-12-10 13:38             ` Florian Weimer
2021-12-10 13:44               ` Adhemerval Zanella
2021-12-10 13:53                 ` Andreas Schwab
2021-12-10 13:56                   ` Adhemerval Zanella

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=32567bed-9014-3db5-371a-56d4a8420966@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@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).