* tests/test-getlogin_r.c: Include xalloc.h.
(main): Pass a writable string to putenv().
* modules/getlogin_r-tests (Depends-on): Add xalloc.
(Makefile.am): Link the program with libintl when needed.
2025-04-13 Bruno Haible <bruno@clisp.org>
+ getlogin_r tests: Avoid writing to a literal string.
+ * tests/test-getlogin_r.c: Include xalloc.h.
+ (main): Pass a writable string to putenv().
+ * modules/getlogin_r-tests (Depends-on): Add xalloc.
+ (Makefile.am): Link the program with libintl when needed.
+
getlogin tests: Avoid writing to a literal string.
* tests/test-getlogin.c: Include xalloc.h.
(main): Pass a writable string to putenv().
Depends-on:
bool
+xalloc
configure.ac:
Makefile.am:
TESTS += test-getlogin_r
check_PROGRAMS += test-getlogin_r
-test_getlogin_r_LDADD = $(LDADD) $(GETLOGIN_LIB)
+test_getlogin_r_LDADD = $(LDADD) @LIBINTL@ $(GETLOGIN_LIB)
#include <config.h>
+/* Specification. */
#include <unistd.h>
#include "signature.h"
SIGNATURE_CHECK (getlogin_r, int, (char *, size_t));
#endif
+#include "xalloc.h"
+
#include "test-getlogin.h"
int
}
/* Check that getlogin_r() does not merely return getenv ("LOGNAME"). */
- putenv ("LOGNAME=ygvfibmslhkmvoetbrcegzwydorcke");
+ putenv (xstrdup ("LOGNAME=ygvfibmslhkmvoetbrcegzwydorcke"));
err = getlogin_r (buf, sizeof buf);
ASSERT (!(err == 0 && strcmp (buf, "ygvfibmslhkmvoetbrcegzwydorcke") == 0));