--- ax25-tools-0.0.5/netrom/nrparms.c.oh2bns Tue Jul 6 23:13:44 1999 +++ ax25-tools-0.0.5/netrom/nrparms.c Wed Sep 1 12:41:07 1999 @@ -37,6 +37,7 @@ { struct nr_route_struct nr_node; char *p, *q, *dev; + int i; if (ax25_config_load_ports() == 0) { fprintf(stderr, "nrparms: nodes: no AX.25 ports configured\n"); @@ -44,7 +45,7 @@ } nr_node.type = NETROM_NODE; - /*nr_node.ndigis = 0;*/ + nr_node.ndigis = 0; if (op[0] != '+' && op[0] != '-') { fprintf(stderr, "nrparms: nodes: invalid operation %s\n", op); @@ -95,7 +96,7 @@ close(s); exit(1); } - /* + for (i = 0; i < AX25_MAX_DIGIS && digis[i] != NULL; i++) { if (ax25_aton_entry(digis[i], nr_node.digipeaters[i].ax25_call) != 0) { fprintf(stderr, "nrparms: invalid callsign %s\n", digis[i]); @@ -103,7 +104,7 @@ exit(1); } nr_node.ndigis++; - } */ + } if ((dev = ax25_config_get_dev(port)) == NULL) { fprintf(stderr, "nrparms: nodes: invalid port name - %s\n", port); --- ax25-tools-0.0.5/user_call/user_io.c.oh2bns Tue Jul 6 23:13:44 1999 +++ ax25-tools-0.0.5/user_call/user_io.c Wed Sep 1 12:37:41 1999 @@ -8,12 +8,14 @@ #include "config.h" #include "user_io.h" +#define BUFLEN 8192 + int compression = 0; int paclen_in = 256; int paclen_out = 256; /* This is for select_loop() */ -static unsigned char buf[8192]; +static unsigned char buf[BUFLEN]; #ifdef HAVE_ZLIB_H #include @@ -22,8 +24,8 @@ static int compression_error = 0; /* These are for the (de)compressor */ -static unsigned char input_buffer[8192]; -static unsigned char output_buffer[8192]; +static unsigned char input_buffer[BUFLEN]; +static unsigned char output_buffer[BUFLEN]; static z_stream incoming_stream; static z_stream outgoing_stream; @@ -62,7 +64,8 @@ int cnt = count; while (cnt > 0) { - write(fd, buf, min(paclen_out, cnt)); + if (write(fd, buf, min(paclen_out, cnt)) < 0) + return -1; buf += paclen_out; cnt -= paclen_out; } @@ -99,7 +102,7 @@ do { /* Set up fixed-size output buffer. */ outgoing_stream.next_out = output_buffer; - outgoing_stream.avail_out = sizeof(output_buffer); + outgoing_stream.avail_out = BUFLEN; /* Compress as much data into the buffer as possible. */ status = deflate(&outgoing_stream, Z_PARTIAL_FLUSH); @@ -111,8 +114,8 @@ } /* Now send the compressed data */ - flush_output(fd, output_buffer, sizeof(output_buffer) - outgoing_stream.avail_out); - + if (flush_output(fd, output_buffer, BUFLEN - outgoing_stream.avail_out) < 0) + return -1; } while (outgoing_stream.avail_out == 0); return count; @@ -158,8 +161,8 @@ incoming_stream.next_in = input_buffer; incoming_stream.avail_in = 0; - if ((len = read(fd, input_buffer, sizeof(input_buffer))) < 0) - return -1; + if ((len = read(fd, input_buffer, BUFLEN)) <= 0) + return len; incoming_stream.avail_in = len; } @@ -173,11 +176,11 @@ fd_set read_fd; int n; - if (fcntl(s, F_SETFL, O_NONBLOCK) == -1) { + if (fcntl(s, F_SETFL, O_NONBLOCK) < 0) { close(s); return -1; } - if (fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK) == -1) { + if (fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK) < 0) { close(s); return -1; } @@ -193,18 +196,18 @@ select(s + 1, &read_fd, NULL, NULL, NULL); if (FD_ISSET(s, &read_fd)) { - while ((n = user_read(s, buf, 8192)) > 0) + while ((n = user_read(s, buf, BUFLEN)) > 0) user_write(STDOUT_FILENO, buf, n); - if (n == 0 || errno != EAGAIN) { + if (n == 0 || (n < 0 && errno != EAGAIN)) { close(s); break; } } if (FD_ISSET(STDIN_FILENO, &read_fd)) { - while ((n = user_read(STDIN_FILENO, buf, 8192)) > 0) + while ((n = user_read(STDIN_FILENO, buf, BUFLEN)) > 0) user_write(s, buf, n); - if (n == 0 || errno != EAGAIN) { + if (n == 0 || (n < 0 && errno != EAGAIN)) { close(s); break; }