diff options
author | Christian Pointner <equinox@anytun.org> | 2008-12-28 21:27:35 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2008-12-28 21:27:35 +0000 |
commit | f8b361e5bcea212fd0635df1b199b2016b14f508 (patch) | |
tree | 18e86ea8873518e3e3172fa4a7dd10dcbec57359 /src | |
parent | added forgotten set functions to packets (diff) |
some cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/cipher.c | 8 | ||||
-rw-r--r-- | src/linux/tun.c | 6 | ||||
-rw-r--r-- | src/options.c | 3 | ||||
-rw-r--r-- | src/uanytun.c | 2 | ||||
-rw-r--r-- | src/udp.c | 3 |
5 files changed, 18 insertions, 4 deletions
diff --git a/src/cipher.c b/src/cipher.c index 02960e4..c473fbc 100644 --- a/src/cipher.c +++ b/src/cipher.c @@ -79,8 +79,10 @@ void cipher_set_key(cipher_t* c, u_int8_t* key, u_int32_t len) if(c->key_.buf_) free(c->key_.buf_); c->key_.buf_ = malloc(len); - if(!c->key_.buf_) + if(!c->key_.buf_) { + c->key_.buf_.length_ = 0; return; + } memcpy(c->key_.buf_, key, len); c->key_.length_ = len; } @@ -95,8 +97,10 @@ void cipher_set_salt(cipher_t* c, u_int8_t* salt, u_int32_t len) if(c->salt_.buf_) free(c->salt_.buf_); c->salt_.buf_ = malloc(len); - if(!c->salt_.buf_) + if(!c->salt_.buf_) { + c->salt_.length_ = 0; return; + } memcpy(c->salt_.buf_, salt, len); c->salt_.length_ = len; } diff --git a/src/linux/tun.c b/src/linux/tun.c index 66485fb..b24f48b 100644 --- a/src/linux/tun.c +++ b/src/linux/tun.c @@ -54,10 +54,12 @@ void tun_init(tun_device_t** dev, const char* dev_name, const char* dev_type, const char* ifcfg_lp, const char* ifcfg_rnmp) { - if(!dev) return; + if(!dev) + return; *dev = malloc(sizeof(tun_device_t)); - if(!*dev) return; + if(!*dev) + return; tun_conf(*dev, dev_name, dev_type, ifcfg_lp, ifcfg_rnmp, 1400); diff --git a/src/options.c b/src/options.c index d2540b1..21ff0bc 100644 --- a/src/options.c +++ b/src/options.c @@ -132,6 +132,9 @@ int options_parse(options_t** opt, int argc, char* argv[]) return -1; *opt = malloc(sizeof(options_t)); + if(!*opt) + return -1; + options_default(*opt); if((*opt)->progname_) diff --git a/src/uanytun.c b/src/uanytun.c index cebfd39..a7e1f7d 100644 --- a/src/uanytun.c +++ b/src/uanytun.c @@ -130,6 +130,8 @@ int main(int argc, char* argv[]) log_init("uanytun", DAEMON); signal_init(); + log_printf(NOTICE, "just started..."); + options_t* opt; int ret = options_parse(&opt, argc, argv); if(ret) { @@ -50,6 +50,7 @@ void udp_init(udp_socket_t** sock, const char* local_addr, const char* port) *sock = malloc(sizeof(udp_socket_t)); if(!*sock) return; + memset(&((*sock)->local_end_), 0, sizeof((*sock)->local_end_)); memset(&((*sock)->remote_end_), 0, sizeof((*sock)->local_end_)); @@ -143,6 +144,8 @@ char* udp_endpoint_to_string(udp_endpoint_t e) return ""; } addrstr = malloc(addrstr_len); + if(!addrstr) + return NULL; inet_ntop (((struct sockaddr *)&e)->sa_family, ptr, addrstr, addrstr_len); char* ret; asprintf(&ret, "%s:%d", addrstr, port); |