From 66251c6c2a063d75634f9991b06a77be5aca12c6 Mon Sep 17 00:00:00 2001 From: Justin Reichardt Date: Thu, 26 Aug 2021 15:13:36 -0500 Subject: [PATCH] Error checking and marking in preserve_static_entr Appends "# rhosts begin\n" after static entries Cleanly errors out if failes to write to tmp file --- src/rhosts.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/rhosts.c b/src/rhosts.c index f9887bb..8cb11e5 100644 --- a/src/rhosts.c +++ b/src/rhosts.c @@ -136,10 +136,21 @@ int preserve_static_entries(){ if (strncmp(buff, "# rhosts begin", 14) == 0){c = EOF;} if (c == '\n'){ rc = fputs(buff, tmpf); + if (rc == EOF){ + fclose(hostsf); + fclose(tmpf); + return 1; + } printf("%s",buff); buff[0] = '\0'; } }while ( c != EOF); + rc = fputs("# rhosts begin\n", tmpf); + if (rc == EOF){ + fclose(hostsf); + fclose(tmpf); + return 1; + }