diff options
author | Philipp Tölke <toelke@in.tum.de> | 2010-07-20 22:22:04 +0000 |
---|---|---|
committer | Philipp Tölke <toelke@in.tum.de> | 2010-07-20 22:22:04 +0000 |
commit | bb3cab0f4f764be314670a19a7468d4ccd87c089 (patch) | |
tree | 4761d686305e7c719d3591f9310182f216d80a15 | |
parent | f2b9b53569e26dbbd5aab101c0e58e4cc31654fe (diff) | |
download | gnunet-bb3cab0f4f764be314670a19a7468d4ccd87c089.tar.gz gnunet-bb3cab0f4f764be314670a19a7468d4ccd87c089.zip |
only read as much as fits inside of a GNUNET_Message
-rw-r--r-- | src/vpn/gnunet-vpn-helper.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/vpn/gnunet-vpn-helper.c b/src/vpn/gnunet-vpn-helper.c index 1d0b1ad28..4a75182f9 100644 --- a/src/vpn/gnunet-vpn-helper.c +++ b/src/vpn/gnunet-vpn-helper.c | |||
@@ -48,6 +48,8 @@ | |||
48 | #ifndef _LINUX_IN6_H | 48 | #ifndef _LINUX_IN6_H |
49 | // This is in linux/include/net/ipv6.h. | 49 | // This is in linux/include/net/ipv6.h. |
50 | 50 | ||
51 | #define MAX_SIZE (65535 - sizeof(struct GNUNET_MessageHeader)) | ||
52 | |||
51 | struct in6_ifreq { | 53 | struct in6_ifreq { |
52 | struct in6_addr ifr6_addr; | 54 | struct in6_addr ifr6_addr; |
53 | __u32 ifr6_prefixlen; | 55 | __u32 ifr6_prefixlen; |
@@ -112,7 +114,7 @@ void setnonblocking(int fd) {/*{{{*/ | |||
112 | }/*}}}*/ | 114 | }/*}}}*/ |
113 | 115 | ||
114 | int main(int argc, char** argv) { | 116 | int main(int argc, char** argv) { |
115 | unsigned char buf[65600]; // 64k + 64; | 117 | unsigned char buf[MAX_SIZE]; |
116 | 118 | ||
117 | char dev[IFNAMSIZ]; | 119 | char dev[IFNAMSIZ]; |
118 | memset(dev, 0, IFNAMSIZ); | 120 | memset(dev, 0, IFNAMSIZ); |
@@ -203,7 +205,7 @@ outer: | |||
203 | } | 205 | } |
204 | } else if (write_stdout_possible && FD_ISSET(fd_tun, &fds_r)) { | 206 | } else if (write_stdout_possible && FD_ISSET(fd_tun, &fds_r)) { |
205 | write_stdout_possible = 0; | 207 | write_stdout_possible = 0; |
206 | r = read(fd_tun, buf, 65600); | 208 | r = read(fd_tun, buf, MAX_SIZE); |
207 | if (r <= 0) { | 209 | if (r <= 0) { |
208 | fprintf(stderr, "read-error: %m\n"); | 210 | fprintf(stderr, "read-error: %m\n"); |
209 | shutdown(fd_tun, SHUT_RD); | 211 | shutdown(fd_tun, SHUT_RD); |