Skip to content

Commit

Permalink
Fix test-0cf405b0 for newer versions of glibc.
Browse files Browse the repository at this point in the history
Newer versions of glibc apparently enforce argv to contain at least one
argument, regardless of what what passed to execlp(). This behavioral
change resulted in test-0cf405b0 performing an endless loop.

This commit addresses this problem by setting an environment variable to
indicate, whether the execlp() call has already been performed.
  • Loading branch information
KimonHoffmann authored and oxr463 committed Apr 23, 2023
1 parent 8d94d2a commit 10dd605
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/test-0cf405b0.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include <unistd.h> /* execlp(2), */
#include <stdlib.h> /* exit(3), */
#include <stdlib.h> /* exit(3), getenv(3), setenv(3)*/
#include <string.h> /* strcmp(3), */

int main(int argc, char *argv[])
{
if (argc == 0) //strcmp(argv[0], "/proc/self/exe") == 0)
if (getenv("PROC_SELF_EXE") != NULL)
exit(EXIT_SUCCESS);

setenv("PROC_SELF_EXE", "1", 1);
execlp("/proc/self/exe", NULL);
exit(EXIT_FAILURE);
}

0 comments on commit 10dd605

Please sign in to comment.