public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* mismatch of type of ut_tv.tv_sec between glibc-2.41 and utmp(5)
@ 2025-02-28  9:36 Dr. Thomas Orgis
  2025-02-28 12:18 ` Florian Weimer
  2025-02-28 14:06 ` Alejandro Colomar
  0 siblings, 2 replies; 5+ messages in thread
From: Dr. Thomas Orgis @ 2025-02-28  9:36 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: linux-man

Dear man-pages,

while investigating some old bad usage of time(&ut,ut_time) I noticed
that my glibc-2.41 headers define that part of the utmp struct like this:

#if __WORDSIZE_TIME64_COMPAT32
  int32_t ut_session;           /* Session ID, used for windowing.  */
  struct
  {
    __uint32_t tv_sec;          /* Seconds.  */
    int32_t tv_usec;            /* Microseconds.  */
  } ut_tv;                      /* Time entry was made.  */
#else
  long int ut_session;          /* Session ID, used for windowing.  */
  struct timeval ut_tv;         /* Time entry was made.  */
#endif

The man page claims this:

           #if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
               int32_t ut_session;           /* Session ID (getsid(2)),
                                                used for windowing */
               struct {
                   int32_t tv_sec;           /* Seconds */
                   int32_t tv_usec;          /* Microseconds */
               } ut_tv;                      /* Time entry was made */
           #else
                long   ut_session;           /* Session ID */
                struct timeval ut_tv;        /* Time entry was made */
           #endif

I don't know the history … did it use to be a signed integer and
someone decided to buy some time by making it unsigned? This is a minor
detail for the bad time() usage, where 32 bit vs. 64 bit time_t might
be more serious. Also the macros being checked for this compatibility
mode differ, but I am not sure how closely the man page want to follow
glibc here.

At least the type of tv_sec should match, I guess.

Now I have to think how elaborately I want to handle possible overflow
from time_t assigning to uint32_t with the recommended way of using
gettimeofday() for utmp …


Regards,

Thomas

-- 
Dr. Thomas Orgis
HPC @ Universität Hamburg

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

end of thread, other threads:[~2025-03-03  9:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-28  9:36 mismatch of type of ut_tv.tv_sec between glibc-2.41 and utmp(5) Dr. Thomas Orgis
2025-02-28 12:18 ` Florian Weimer
2025-02-28 14:06 ` Alejandro Colomar
2025-03-03  9:31   ` Dr. Thomas Orgis
2025-03-03  9:47     ` Alejandro Colomar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox