[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SCM] Debian package checker branch, master, updated. 2.5.9-2-gc0c4c9a



The following commit has been merged in the master branch:
commit c0c4c9a08fa25ba5d14ffbb7578cf28c3d978f2f
Author: Niels Thykier <niels@thykier.net>
Date:   Sat Jun 16 14:00:05 2012 +0200

    L::Util: Fix truncation of file in touch_file
    
    So far this has not been an issue because all uses have only involved
    empty (or non-existent) files.
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/lib/Lintian/Util.pm b/lib/Lintian/Util.pm
index f601335..d9714c7 100644
--- a/lib/Lintian/Util.pm
+++ b/lib/Lintian/Util.pm
@@ -759,11 +759,15 @@ the failure.
 
 =cut
 
-# create an empty file
-# --okay, okay, this is not exactly what `touch' does :-)
 sub touch_file {
-    open(T, '>', $_[0]) or return 0;
-    close(T) or return 0;
+    my ($file) = @_;
+    # We use '>>' because '>' truncates the file if it has contents
+    # (which `touch file` doesn't).
+    open my $fd, '>>', $file or return 0;
+    close $fd or return 0;
+    # open with '>>' does not update the mtime if the file already
+    # exists, so use utime to solve that.
+    utime undef, undef, $file or return 0;
 
     return 1;
 }

-- 
Debian package checker


Reply to: