From 49cd2f3a7b986c4248c93daddf3aac5ba11b8756 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sun, 26 Jun 2011 21:19:41 +0200 Subject: [PATCH] Prevent the use of /dev/null for saving the content file. It's dangerous because it renames it! --- state.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/state.c b/state.c index 440b7240..fa0f2c45 100644 --- a/state.c +++ b/state.c @@ -622,6 +622,10 @@ static void state_write_one(struct snapraid_state* state, const char* path, unsi printf("Saving state to %s...\n", path); + /* ignore some special files */ + if (strcmp(path, "/dev/null") == 0 || strcmp(path, "NUL") == 0) + return; + pathprint(tmp, sizeof(tmp), "%s.tmp", path); f = fopen(tmp, "wt"); if (!f) {