cmd_config: replace action magic numbers with enum
[tinc] / src / protocol_auth.c
index 19859b7..0e6ac5d 100644 (file)
@@ -25,7 +25,6 @@
 #include "control.h"
 #include "control_common.h"
 #include "cipher.h"
-#include "crypto.h"
 #include "digest.h"
 #include "ecdsa.h"
 #include "edge.h"
@@ -42,6 +41,7 @@
 #include "sptps.h"
 #include "utils.h"
 #include "xalloc.h"
+#include "random.h"
 
 #include "ed25519/sha512.h"
 #include "keys.h"
@@ -296,6 +296,7 @@ static bool receive_invitation_sptps(void *handle, uint8_t type, const void *dat
 
        if(!fgets(buf, sizeof(buf), f)) {
                logger(DEBUG_ALWAYS, LOG_ERR, "Could not read invitation file %s\n", cookie);
+               fclose(f);
                return false;
        }
 
@@ -336,6 +337,12 @@ static bool receive_invitation_sptps(void *handle, uint8_t type, const void *dat
                sptps_send_record(&c->sptps, 0, buf, result);
        }
 
+       if(!feof(f)) {
+               logger(DEBUG_ALWAYS, LOG_ERR, "Could not read invitation file %s\n", cookie);
+               fclose(f);
+               return false;
+       }
+
        sptps_send_record(&c->sptps, 1, buf, 0);
        fclose(f);
        unlink(usedname);