]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Abort deleting user when an error prevent writing new file
authorPatrice Fournier <patrice.fournier@ifax.com>
Thu, 4 Feb 2021 03:43:36 +0000 (22:43 -0500)
committerPatrice Fournier <patrice.fournier@ifax.com>
Mon, 5 Aug 2024 09:42:35 +0000 (05:42 -0400)
hfaxd/User.c++

index f7749a5544c4a29e96ae1e53a681a7b64b993c08..3701c82a6b31f1b407f29113a6ea2f02e8764727 100644 (file)
@@ -502,11 +502,21 @@ HylaFAXServer::deleteUser(FILE* db, const char* user)
                break;
            }
        }
-       fputs(line, ftmp);
+       if (fputs(line, ftmp) == EOF) {
+           perror_reply(550, "Write error", errno);
+           fclose(ftmp);
+           (void) Sys::unlink(tfile);
+           return (false);
+       }
     }
     int cc;
     while ((cc = fread(line, 1, sizeof (line), db)) > 0)
-       fwrite(line, cc, 1, ftmp);
+       if (fwrite(line, cc, 1, ftmp) != 1) {
+           perror_reply(550, "Write error", errno);
+           fclose(ftmp);
+           (void) Sys::unlink(tfile);
+           return (false);
+       }
     bool ioError = (fclose(ftmp) != 0);
     if (found) {
        if (ioError)