diff options
Diffstat (limited to 'fileio.c')
-rw-r--r-- | fileio.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -2,7 +2,6 @@ #include "wfm.h" - /* // Debug dump vars //void debugdumpvars(void) { @@ -104,6 +103,9 @@ void receivefile(void) { if(!output) error("Unable to open file %s for writing.<BR>%s", virt_filename, strerror(errno)); + if(flock(fileno(output), LOCK_EX) == -1) + error("Unable to lock file %s.<BR>%s", virt_filename, strerror(errno)); + while(cgiFormFileRead(input, buff, sizeof(buff), &got) == cgiFormSuccess) if(got) if(fwrite(buff, got, 1, output) != 1) @@ -221,6 +223,9 @@ void edit_save(void) { if(!tempf) error("Unable to open temporary file %s.<BR>%s", basename(tempname), strerror(errno)); + if(flock(fileno(tempf), LOCK_EX) == -1) + error("Unable to lock file %s.<BR>%s", basename(tempname), strerror(errno)); + if(fwrite(buff, strlen(buff), 1, tempf) != 1) error("Unable to write to temporary file %s.<BR>%s", basename(tempname), strerror(errno)); |