[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
segfault on ENVIRON access (5.1.1 but NOT in latest git)
From: |
Mathieu Bivert |
Subject: |
segfault on ENVIRON access (5.1.1 but NOT in latest git) |
Date: |
Wed, 3 Aug 2022 06:22:53 +0200 |
Hello,
I've hit a systematically reproducible segfault on ENVIRON access
on gawk-5.1.1, but not anymore with the latest git commit (381d737c).
I haven't looked too deep into the changelog/mailing list to see if it's
actually relevant; I prefer to notify you, just in case there's something
else lurking around.
Segfault occurs, among others, when **environ starts with a variable
named 0 (zero):
% uname -a
Linux earth 5.17.9-arch1-1 #1 SMP PREEMPT Wed, 18 May 2022 17:30:11
+0000 x86_64 GNU/Linux
% cat test.c && cc test.c && echo | ./a.out
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
extern char **environ;
char *gawk = "/home/mb/src/gawk-5.1.1/gawk";
int main(void)
{
char *argv[] = {
"gawk",
"{\n\
for (k in ENVIRON)\n\
printf(\"ENV[%s] = %s\\n\", k, ENVIRON[k])\n\
}",
NULL
};
/* assuming environ contains at least one variable */
environ[0] = strdup("0=whatever");
if (environ[0] == NULL) {
perror("strdup()");
return -1;
}
execv(gawk, argv);
return 0;
}
gawk: cmd. line:2: (FILENAME=- FNR=1) fatal error: internal error:
segfault
Aborted (core dumped)
Cheers,
- segfault on ENVIRON access (5.1.1 but NOT in latest git),
Mathieu Bivert <=