rdm++;
if (fseek(fp, 0, SEEK_SET) == -1 ||
ftruncate(fileno(fp), 0) == -1 ||
- fprintf(fp, "0x%016" PRIu64 "\n", rdm) != 19)
+ fprintf(fp, "0x%016" PRIu64 "\n", rdm) != 19 ||
+ fflush(fp) == EOF)
{
if (!auth->last_replay_set) {
auth->last_replay = rdm;
rdm = ++auth->last_replay;
/* report error? */
}
- fflush(fp);
#ifdef LOCK_EX
if (flocked == 0)
flock(fileno(fp), LOCK_UN);
}
len = duid_make(d, ifp, DUID_LLT);
x = fprintf(fp, "%s\n", hwaddr_ntoa(d, len, line, sizeof(line)));
- fclose(fp);
+ if (fclose(fp) == EOF)
+ x = -1;
/* Failed to write the duid? scrub it, we cannot use it */
if (x < 1) {
logger(ifp->ctx, LOG_ERR, "error writing DUID: %s: %m", DUID);
goto eexit;
x = fprintf(fp, "%s\n",
hwaddr_ntoa(ctx->secret, ctx->secret_len, line, sizeof(line)));
- fclose(fp);
+ if (fclose(fp) == EOF)
+ x = -1;
if (x > 0)
return (ssize_t)ctx->secret_len;