[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19520: shuf: extra operand handling with -i
From: |
Daiki Ueno |
Subject: |
bug#19520: shuf: extra operand handling with -i |
Date: |
Tue, 06 Jan 2015 12:14:02 +0900 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
I heard that shuf causes a segmentation fault if an extra argument is
given with the -i option:
$ shuf -i0-0 1
zsh: segmentation fault (core dumped) shuf -i0-0 1
the crash is in quotearg.c, where NULL is passed as an input.
I'm attaching a patch.
>From daa0873ff9197a687a086409f4ce77a7856ab72d Mon Sep 17 00:00:00 2001
From: Daiki Ueno <address@hidden>
Date: Tue, 6 Jan 2015 11:51:59 +0900
Subject: [PATCH] shuf: fix extra operand handling with -i
* src/shuf.c (main): When the input is a range, use argv[optind]
as the first extra operand, instead of argv[optind + 1].
---
src/shuf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/shuf.c b/src/shuf.c
index 75211bd..d31dc91 100644
--- a/src/shuf.c
+++ b/src/shuf.c
@@ -501,7 +501,7 @@ main (int argc, char **argv)
}
if (input_range ? 0 < n_operands : !echo && 1 < n_operands)
{
- error (0, 0, _("extra operand %s"), quote (operand[1]));
+ error (0, 0, _("extra operand %s"), quote (operand[input_range ? 0 :
1]));
usage (EXIT_FAILURE);
}
--
2.1.0
Regards,
--
Daiki Ueno
- bug#19520: shuf: extra operand handling with -i,
Daiki Ueno <=