Don't check for NULL-pointers before calling free().
[tinc] / src / protocol_auth.c
index 9d61ab8..3a84c22 100644 (file)
@@ -176,6 +176,8 @@ bool send_id(connection_t *c) {
 }
 
 static bool finalize_invitation(connection_t *c, const char *data, uint16_t len) {
+       (void)len;
+
        if(strchr(data, '\n')) {
                logger(DEBUG_ALWAYS, LOG_ERR, "Received invalid key from invited node %s (%s)!\n", c->name, c->hostname);
                return false;
@@ -405,10 +407,7 @@ bool id_h(connection_t *c, const char *request) {
                        return false;
                }
        } else {
-               if(c->name) {
-                       free(c->name);
-               }
-
+               free(c->name);
                c->name = xstrdup(name);
        }
 
@@ -606,7 +605,7 @@ bool metakey_h(connection_t *c, const char *request) {
 
        /* Convert the challenge from hexadecimal back to binary */
 
-       int inlen = hex2bin(hexkey, enckey, sizeof(enckey));
+       size_t inlen = hex2bin(hexkey, enckey, sizeof(enckey));
 
        /* Check if the length of the meta key is all right */
 
@@ -762,7 +761,7 @@ bool chal_reply_h(connection_t *c, const char *request) {
 
        /* Convert the hash to binary format */
 
-       int inlen = hex2bin(hishash, hishash, sizeof(hishash));
+       size_t inlen = hex2bin(hishash, hishash, sizeof(hishash));
 
        /* Check if the length of the hash is all right */