projects
/
tinc
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
987f2a3
)
Fix a few more issues found by Coverity.
author
Guus Sliepen
<guus@tinc-vpn.org>
Tue, 6 May 2014 20:12:47 +0000
(22:12 +0200)
committer
Guus Sliepen
<guus@tinc-vpn.org>
Tue, 6 May 2014 20:12:47 +0000
(22:12 +0200)
src/avl_tree.c
patch
|
blob
|
history
src/net_setup.c
patch
|
blob
|
history
src/net_socket.c
patch
|
blob
|
history
src/raw_socket_device.c
patch
|
blob
|
history
src/xmalloc.c
patch
|
blob
|
history
diff --git
a/src/avl_tree.c
b/src/avl_tree.c
index
4b23756
..
22d7ff5
100644
(file)
--- a/
src/avl_tree.c
+++ b/
src/avl_tree.c
@@
-168,14
+168,12
@@
static void avl_rebalance(avl_tree_t *tree, avl_node_t *node)
child->right->parent = child;
gchild->right = node;
child->right->parent = child;
gchild->right = node;
- if(gchild->right)
- gchild->right->parent = gchild;
+ gchild->right->parent = gchild;
gchild->left = child;
gchild->left = child;
- if(gchild->left)
- gchild->left->parent = gchild;
- *superparent = gchild;
+ gchild->left->parent = gchild;
+ *superparent = gchild;
gchild->parent = parent;
#ifdef AVL_COUNT
node->count = AVL_CALC_COUNT(node);
gchild->parent = parent;
#ifdef AVL_COUNT
node->count = AVL_CALC_COUNT(node);
@@
-224,8
+222,7
@@
static void avl_rebalance(avl_tree_t *tree, avl_node_t *node)
child->left->parent = child;
gchild->left = node;
child->left->parent = child;
gchild->left = node;
- if(gchild->left)
- gchild->left->parent = gchild;
+ gchild->left->parent = gchild;
gchild->right = child;
gchild->right->parent = gchild;
gchild->right = child;
gchild->right->parent = gchild;
diff --git
a/src/net_setup.c
b/src/net_setup.c
index
9f25fb9
..
60335fd
100644
(file)
--- a/
src/net_setup.c
+++ b/
src/net_setup.c
@@
-578,6
+578,7
@@
static bool setup_myself(void) {
addressfamily = AF_UNSPEC;
else {
logger(LOG_ERR, "Invalid address family!");
addressfamily = AF_UNSPEC;
else {
logger(LOG_ERR, "Invalid address family!");
+ free(afname);
return false;
}
free(afname);
return false;
}
free(afname);
@@
-595,6
+596,7
@@
static bool setup_myself(void) {
if(!myself->incipher) {
logger(LOG_ERR, "Unrecognized cipher type!");
if(!myself->incipher) {
logger(LOG_ERR, "Unrecognized cipher type!");
+ free(cipher);
return false;
}
}
return false;
}
}
diff --git
a/src/net_socket.c
b/src/net_socket.c
index
cfcf1c3
..
4beb665
100644
(file)
--- a/
src/net_socket.c
+++ b/
src/net_socket.c
@@
-102,7
+102,6
@@
static bool bind_to_interface(int sd) {
return false;
}
return false;
}
- free(iface);
#else /* if !defined(SOL_SOCKET) || !defined(SO_BINDTODEVICE) */
logger(LOG_WARNING, "%s not supported on this platform", "BindToInterface");
#endif
#else /* if !defined(SOL_SOCKET) || !defined(SO_BINDTODEVICE) */
logger(LOG_WARNING, "%s not supported on this platform", "BindToInterface");
#endif
diff --git
a/src/raw_socket_device.c
b/src/raw_socket_device.c
index
c61e43c
..
a5cd835
100644
(file)
--- a/
src/raw_socket_device.c
+++ b/
src/raw_socket_device.c
@@
-62,10
+62,11
@@
static bool setup_device(void) {
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_ifrn.ifrn_name, iface, IFNAMSIZ);
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_ifrn.ifrn_name, iface, IFNAMSIZ);
+ ifr.ifr_ifrn.ifrn_name[IFNAMSIZ - 1] = 0;
+
if(ioctl(device_fd, SIOCGIFINDEX, &ifr)) {
close(device_fd);
if(ioctl(device_fd, SIOCGIFINDEX, &ifr)) {
close(device_fd);
- logger(LOG_ERR, "Can't find interface %s: %s", iface,
- strerror(errno));
+ logger(LOG_ERR, "Can't find interface %s: %s", ifr.ifr_ifrn.ifrn_name, strerror(errno));
return false;
}
return false;
}
@@
-75,7
+76,7
@@
static bool setup_device(void) {
sa.sll_ifindex = ifr.ifr_ifindex;
if(bind(device_fd, (struct sockaddr *) &sa, (socklen_t) sizeof(sa))) {
sa.sll_ifindex = ifr.ifr_ifindex;
if(bind(device_fd, (struct sockaddr *) &sa, (socklen_t) sizeof(sa))) {
- logger(LOG_ERR, "Could not bind %s to %s: %s", device, if
ac
e, strerror(errno));
+ logger(LOG_ERR, "Could not bind %s to %s: %s", device, if
r.ifr_ifrn.ifrn_nam
e, strerror(errno));
return false;
}
return false;
}
diff --git
a/src/xmalloc.c
b/src/xmalloc.c
index
1e40017
..
a687433
100644
(file)
--- a/
src/xmalloc.c
+++ b/
src/xmalloc.c
@@
-115,7
+115,7
@@
char *xstrdup(const char *s)
p = strdup(s);
if(!p)
p = strdup(s);
if(!p)
- xalloc_fail (
(int)strlen(s)
);
+ xalloc_fail (
s ? (int)strlen(s) : 0
);
return p;
}
return p;
}