Mercurial > hg > quicktun
comparison src/common.c @ 12:e4b60d041491
Make sure that the session buffer is zero
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Sun, 05 Dec 2010 23:12:04 +0100 |
parents | 640f620a55cf |
children | f7e0145d8e2a |
comparison
equal
deleted
inserted
replaced
11:5be1ecb80cc9 | 12:e4b60d041491 |
---|---|
114 if (bind(sfd, (struct sockaddr*)&udpaddr, sizeof(struct sockaddr_in))) return errorexitp("Could not bind socket"); | 114 if (bind(sfd, (struct sockaddr*)&udpaddr, sizeof(struct sockaddr_in))) return errorexitp("Could not bind socket"); |
115 if (!(envval = getconf("REMOTE_ADDRESS"))) { | 115 if (!(envval = getconf("REMOTE_ADDRESS"))) { |
116 session->remote_float = 1; | 116 session->remote_float = 1; |
117 //return errorexit("Missing REMOTE_ADDRESS"); | 117 //return errorexit("Missing REMOTE_ADDRESS"); |
118 } else { | 118 } else { |
119 session->remote_float = 0; | 119 session->remote_float = getconf("REMOTE_FLOAT") ? 1 : 0; |
120 he = gethostbyname(envval); | 120 he = gethostbyname(envval); |
121 if (!he) return errorexit("remote address lookup failed"); | 121 if (!he) return errorexit("remote address lookup failed"); |
122 else if (!he->h_addr_list[0]) return errorexit("no address to connect to"); | 122 else if (!he->h_addr_list[0]) return errorexit("no address to connect to"); |
123 udpaddr.sin_family = he->h_addrtype; | 123 udpaddr.sin_family = he->h_addrtype; |
124 udpaddr.sin_addr.s_addr = *((unsigned long*)he->h_addr_list[0]); | 124 udpaddr.sin_addr.s_addr = *((unsigned long*)he->h_addr_list[0]); |
180 session.fd_dev = init_tuntap(); | 180 session.fd_dev = init_tuntap(); |
181 int ttfd = session.fd_dev; | 181 int ttfd = session.fd_dev; |
182 if (ttfd == -1) return -1; | 182 if (ttfd == -1) return -1; |
183 | 183 |
184 char protocol_data[p->protocol_data_size]; | 184 char protocol_data[p->protocol_data_size]; |
185 memset(protocol_data, 0, p->protocol_data_size); | |
185 session.protocol_data = &protocol_data; | 186 session.protocol_data = &protocol_data; |
186 if (p->init) p->init(&session); | 187 if (p->init) p->init(&session); |
187 | 188 |
188 fprintf(stderr, "The tunnel is now operational!\n"); | 189 fprintf(stderr, "The tunnel is now operational!\n"); |
189 | 190 |