aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-08-06 12:28:24 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-08-06 12:28:24 +0000
commit8e209c3787f3b7d7bda3915afc6df0604b60707c (patch)
tree5704e9f6b237952d7793571b151899aceec32f84
parent73f21e9cb3aaa6f1643d2edc4f6abceda9a17834 (diff)
downloadbusybox-w32-8e209c3787f3b7d7bda3915afc6df0604b60707c.tar.gz
busybox-w32-8e209c3787f3b7d7bda3915afc6df0604b60707c.tar.bz2
busybox-w32-8e209c3787f3b7d7bda3915afc6df0604b60707c.zip
catv: catv without arguments was trying to use environ as argv.
(Alex Landau <landau_alex@yahoo.com>)
-rw-r--r--coreutils/catv.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/coreutils/catv.c b/coreutils/catv.c
index 876b67a2a..0ca73a0c9 100644
--- a/coreutils/catv.c
+++ b/coreutils/catv.c
@@ -15,7 +15,8 @@
15int catv_main(int argc, char **argv); 15int catv_main(int argc, char **argv);
16int catv_main(int argc, char **argv) 16int catv_main(int argc, char **argv)
17{ 17{
18 int retval = EXIT_SUCCESS, fd; 18 int retval = EXIT_SUCCESS;
19 int fd;
19 unsigned flags; 20 unsigned flags;
20 21
21 flags = getopt32(argc, argv, "etv"); 22 flags = getopt32(argc, argv, "etv");
@@ -27,8 +28,10 @@ int catv_main(int argc, char **argv)
27 28
28 /* Read from stdin if there's nothing else to do. */ 29 /* Read from stdin if there's nothing else to do. */
29 fd = 0; 30 fd = 0;
30 if (!argv[0]) 31 if (!argv[0]) {
32 argv--;
31 goto jump_in; 33 goto jump_in;
34 }
32 do { 35 do {
33 fd = open_or_warn(*argv, O_RDONLY); 36 fd = open_or_warn(*argv, O_RDONLY);
34 if (fd < 0) { 37 if (fd < 0) {
@@ -46,7 +49,7 @@ int catv_main(int argc, char **argv)
46 if (res < 1) 49 if (res < 1)
47 break; 50 break;
48 for (i = 0; i < res; i++) { 51 for (i = 0; i < res; i++) {
49 char c = read_buf[i]; 52 unsigned char c = read_buf[i];
50 53
51 if (c > 126 && (flags & CATV_OPT_v)) { 54 if (c > 126 && (flags & CATV_OPT_v)) {
52 if (c == 127) { 55 if (c == 127) {