]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3408: Wrong header length leads to EFAULTs when cretating UFS swap.log.new.
authorMatthias Pitzl <silamael@coronamundi.de>
Tue, 8 Nov 2011 15:00:17 +0000 (08:00 -0700)
committerAlex Rousskov <rousskov@measurement-factory.com>
Tue, 8 Nov 2011 15:00:17 +0000 (08:00 -0700)
Also localized the header variable as it may be destroyed at any time.

src/fs/ufs/store_dir_ufs.cc

index 7ee1df8cf552abed658b78de0b9ce51a608ca2b8..449d5d6f0fea8c10d6eda3b999f6af27c6cf5a64 100644 (file)
@@ -777,7 +777,6 @@ UFSSwapDir::openTmpSwapLog(int *clean_flag, int *zero_flag)
     struct stat clean_sb;
     FILE *fp;
     int fd;
-    StoreSwapLogHeader *head;
 
     if (::stat(swaplog_path, &log_sb) < 0) {
         debugs(47, 1, "Cache Dir #" << index << ": No log file");
@@ -803,10 +802,11 @@ UFSSwapDir::openTmpSwapLog(int *clean_flag, int *zero_flag)
 
     swaplog_fd = fd;
 
-    head = new StoreSwapLogHeader;
-
-    file_write(swaplog_fd, -1, head, head->record_size,
-               NULL, NULL, FreeHeader);
+    {
+        StoreSwapLogHeader *header = new StoreSwapLogHeader;
+        file_write(swaplog_fd, -1, header, sizeof(*header),
+                   NULL, NULL, FreeHeader);
+    }
 
     /* open a read-only stream of the old log */
     fp = fopen(swaplog_path, "rb");