[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: segfault on ENVIRON access (5.1.1 but NOT in latest git)
From: |
arnold |
Subject: |
Re: segfault on ENVIRON access (5.1.1 but NOT in latest git) |
Date: |
Wed, 03 Aug 2022 01:57:44 -0600 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
Hi.
Thank you for reporting a bug. This issue was reported recently and that's
why it's fixed in Git master. I'm working on a new release, so that release
will have the fix in it.
Much thanks,
Arnold
Mathieu Bivert <mathieu.bivert@gmail.com> wrote:
> 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,