bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] readutmp: work around glibc utmpx bug


From: Bruno Haible
Subject: Re: [PATCH] readutmp: work around glibc utmpx bug
Date: Sun, 30 Jul 2023 15:21:50 +0200

Paul Eggert wrote:
> +static void
> +copy_utmp_entry (STRUCT_UTMP *dst, STRUCT_UTMP *src)
> +{
> +#if __GLIBC__ && _TIME_BITS == 64
> +  /* Convert from external form in SRC to internal form in DST.
> +     It is OK to convert now, rather than earlier, before
> +     desirable_utmp_entry was invoked, because desirable_utmp_entry
> +     inspects only the leading prefix of the entry, which is the
> +     same in both external and internal forms.  */

This code needs a unit test, if it wants to be future-proof. I'm
therefore adding one, and a few comment tweaks (as the existing
comments did not make everything 100% clear).


2023-07-30  Bruno Haible  <bruno@clisp.org>

        readutmp: Add tests.
        * tests/test-readutmp.c: New file.
        * modules/readutmp-tests: New file.

        readutmp: Improve comments. Fix module description.
        * lib/readutmp.h (extract_trimmed_name): Add specification comment.
        (read_utmp): Move specification comment from lib/readutmp.c to here.
        Mention also UTMP_FILE and READ_UTMP_USER_PROCESS.
        * lib/readutmp.c (extract_trimmed_name): Fix comment.
        * modules/readutmp (Include): Only include the .h file if
        HAVE_UTMPX_H || HAVE_UTMP_H.


The results of this unit test are:

* I reproduce the previous bug (fixed through your patch) on
    - Ubuntu 22.04 (glibc 2.35) in 32-bit mode
* I do not reproduce the previous bug on
    - Ubuntu 22.04 (glibc 2.35) in x32 mode
    - Manjaro 17 (glibc 2.28) in 32-bit mode
    - Ubuntu 18.04 (glibc 2.27) in 32-bit mode
    - openSUSE 12.1 (glibc 2.14.1) in 32-bit mode
    - Debian 9.1 (glibc 2.24)
    - Slackware 14 (glibc 2.15)
    - Slackware 13 (glibc 2.13)
* The test succeeds on
    - macOS, FreeBSD, NetBSD, AIX, Solaris 10 and 11
* The test succeeds trivially, with no file being read, on
    - Alpine Linux 3.18, Cygwin 3.4.6, Android 13
* The test fails on OpenBSD 7.2, because the smallest time in the entries
  is 1970-01-01.
* The test is skipped on native Windows.

Attachment: 0001-readutmp-Improve-comments.-Fix-module-description.patch
Description: Text Data

Attachment: 0002-readutmp-Add-tests.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]