Fix a file descriptor leak when something goes wrong while reading an
invitation file. Also check that we read it in full before committing.
Found by cppcheck.
if(!fgets(buf, sizeof(buf), f)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Could not read invitation file %s\n", cookie);
+ fclose(f);
return false;
}
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);