diff options
Diffstat (limited to 'src/usr.bin/nc/netcat.c')
-rw-r--r-- | src/usr.bin/nc/netcat.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c index 88dde5290b..36d133a2bb 100644 --- a/src/usr.bin/nc/netcat.c +++ b/src/usr.bin/nc/netcat.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: netcat.c,v 1.78 2005/04/10 19:43:34 otto Exp $ */ | 1 | /* $OpenBSD: netcat.c,v 1.79 2005/05/24 20:13:28 avsm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> | 3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> |
4 | * | 4 | * |
@@ -50,6 +50,7 @@ | |||
50 | #include <string.h> | 50 | #include <string.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #include <fcntl.h> | 52 | #include <fcntl.h> |
53 | #include "atomicio.h" | ||
53 | 54 | ||
54 | #ifndef SUN_LEN | 55 | #ifndef SUN_LEN |
55 | #define SUN_LEN(su) \ | 56 | #define SUN_LEN(su) \ |
@@ -80,7 +81,6 @@ int timeout = -1; | |||
80 | int family = AF_UNSPEC; | 81 | int family = AF_UNSPEC; |
81 | char *portlist[PORT_MAX+1]; | 82 | char *portlist[PORT_MAX+1]; |
82 | 83 | ||
83 | ssize_t atomicio(ssize_t (*)(int, void *, size_t), int, void *, size_t); | ||
84 | void atelnet(int, unsigned char *, unsigned int); | 84 | void atelnet(int, unsigned char *, unsigned int); |
85 | void build_ports(char *); | 85 | void build_ports(char *); |
86 | void help(void); | 86 | void help(void); |
@@ -590,7 +590,7 @@ readwrite(int nfd) | |||
590 | { | 590 | { |
591 | struct pollfd pfd[2]; | 591 | struct pollfd pfd[2]; |
592 | unsigned char buf[BUFSIZ]; | 592 | unsigned char buf[BUFSIZ]; |
593 | int wfd = fileno(stdin), n; | 593 | int n, wfd = fileno(stdin); |
594 | int lfd = fileno(stdout); | 594 | int lfd = fileno(stdout); |
595 | 595 | ||
596 | /* Setup Network FD */ | 596 | /* Setup Network FD */ |
@@ -623,8 +623,7 @@ readwrite(int nfd) | |||
623 | } else { | 623 | } else { |
624 | if (tflag) | 624 | if (tflag) |
625 | atelnet(nfd, buf, n); | 625 | atelnet(nfd, buf, n); |
626 | if (atomicio((ssize_t (*)(int, void *, size_t))write, | 626 | if (atomicio(vwrite, lfd, buf, n) != n) |
627 | lfd, buf, n) != n) | ||
628 | return; | 627 | return; |
629 | } | 628 | } |
630 | } | 629 | } |
@@ -637,8 +636,7 @@ readwrite(int nfd) | |||
637 | pfd[1].fd = -1; | 636 | pfd[1].fd = -1; |
638 | pfd[1].events = 0; | 637 | pfd[1].events = 0; |
639 | } else { | 638 | } else { |
640 | if (atomicio((ssize_t (*)(int, void *, size_t))write, | 639 | if (atomicio(vwrite, nfd, buf, n) != n) |
641 | nfd, buf, n) != n) | ||
642 | return; | 640 | return; |
643 | } | 641 | } |
644 | } | 642 | } |
@@ -669,9 +667,8 @@ atelnet(int nfd, unsigned char *buf, unsigned int size) | |||
669 | p++; | 667 | p++; |
670 | obuf[2] = *p; | 668 | obuf[2] = *p; |
671 | obuf[3] = '\0'; | 669 | obuf[3] = '\0'; |
672 | if (atomicio((ssize_t (*)(int, void *, size_t))write, | 670 | if (atomicio(vwrite, nfd, obuf, 3) != 3) |
673 | nfd, obuf, 3) != 3) | 671 | warn("Write Error!"); |
674 | warnx("Write Error!"); | ||
675 | obuf[0] = '\0'; | 672 | obuf[0] = '\0'; |
676 | } | 673 | } |
677 | } | 674 | } |