2014-02-10 18:14:12 +00:00
|
|
|
From 1638d046d2a914164e19c6244df5b4deadaf6938 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Marius Tomaschewski <mt@suse.de>
|
|
|
|
Date: Thu, 18 Aug 2011 10:06:01 +0200
|
|
|
|
Subject: [PATCH] dhcp-4.1.1-tmpfile
|
|
|
|
|
|
|
|
---
|
|
|
|
server/db.c | 17 ++++++-----------
|
|
|
|
1 file changed, 6 insertions(+), 11 deletions(-)
|
|
|
|
|
2010-05-13 22:27:05 +00:00
|
|
|
diff --git a/server/db.c b/server/db.c
|
2014-02-10 18:14:12 +00:00
|
|
|
index 82f3841..c2630ea 100644
|
2010-05-13 22:27:05 +00:00
|
|
|
--- a/server/db.c
|
|
|
|
+++ b/server/db.c
|
2014-02-10 18:14:12 +00:00
|
|
|
@@ -1088,21 +1088,16 @@ int new_lease_file ()
|
2007-01-10 16:39:58 +00:00
|
|
|
|
|
|
|
db_validity = lease_file_is_corrupt;
|
|
|
|
|
|
|
|
- /* %Audit% Truncated filename causes panic. %2004.06.17,Safe%
|
|
|
|
- * This should never happen since the path is a configuration
|
|
|
|
- * variable from build-time or command-line. But if it should,
|
|
|
|
- * either by malice or ignorance, we panic, since the potential
|
|
|
|
- * for havoc is high.
|
|
|
|
- */
|
|
|
|
- if (snprintf (newfname, sizeof newfname, "%s.%d",
|
|
|
|
- path_dhcpd_db, (int)t) >= sizeof newfname)
|
|
|
|
- log_fatal("new_lease_file: lease file path too long");
|
|
|
|
-
|
|
|
|
- db_fd = open (newfname, O_WRONLY | O_TRUNC | O_CREAT, 0664);
|
|
|
|
+ snprintf (newfname, sizeof(newfname), "%s.XXXXXX", path_dhcpd_db);
|
|
|
|
+ db_fd = mkstemp (newfname);
|
|
|
|
if (db_fd < 0) {
|
|
|
|
log_error ("Can't create new lease file: %m");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
+ if (fchmod(db_fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) == -1) {
|
|
|
|
+ log_error ("Can't fchmod new lease file: %m");
|
|
|
|
+ goto fail;
|
|
|
|
+ }
|
|
|
|
if ((new_db_file = fdopen(db_fd, "w")) == NULL) {
|
|
|
|
log_error("Can't fdopen new lease file: %m");
|
|
|
|
close(db_fd);
|
2014-02-10 18:14:12 +00:00
|
|
|
--
|
|
|
|
1.8.4
|
|
|
|
|