[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: awk negative field access
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2018-04-23 8:54:01
Message-ID: CAK1hOcOfNYu5+TSPtBa_gpvS5CzKYAWNESZFNH+C+LFXxTAWRg () mail ! gmail ! com
[Download RAW message or body]

Applied, thanks!

On Sat, Apr 21, 2018 at 9:36 PM, Anthony DeDominic <anthony@dedominic.pw> wrote:
> It appears busybox v1.28.3 awk is not checking the bounds of field
> access:
>
>   busybox awk '{ print $(-1) }' <<< ''
>   0
>
> using a value high enough will make busybox segfault:
>
>   busybox awk '{ print $(-160) }' <<< ''
>   zsh: segmentation fault (core dumped)  busybox awk '{ print $(-160)
> }' <<< ''
>
> Other awks seem to check for negative field access:
>
>   gawk '{ print $(-1) }' <<< ''
>   gawk: cmd. line:1: (FILENAME=- FNR=1) fatal: attempt to access field
> -1
>
>   mawk '{ print $(-1) }' <<< ''
>   mawk: run time error: negative field index $-1
>         FILENAME="-" FNR=1 NR=1
>
>   nawk '{ print $(-1) }' <<< ''
>   nawk: trying to access out of range field -1
>     input record number 1, file
>     source line number 1
>
> Given how these other awks handle negative field access, this seems
> like a bug.
>
> I have a patch which appears to fix the issue, including a new test
> case.
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
>
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic