[gnome-boxes/gnome-3-8] util: More error handling in get_timezone_from_linux()



commit cea786fcc5d2c57f6c97658b075c37fafdec59ba
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu May 2 18:04:25 2013 +0300

    util: More error handling in get_timezone_from_linux()
    
    https://bugzilla.gnome.org/show_bug.cgi?id=699281

 src/util-app.vala |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/src/util-app.vala b/src/util-app.vala
index 91f6849..94a5c86 100644
--- a/src/util-app.vala
+++ b/src/util-app.vala
@@ -503,11 +503,18 @@ namespace Boxes {
         return timedate.timezone;
     }
 
+    private const string TZ_FILE = "/etc/localtime";
+
     public string get_timezone_from_linux () throws GLib.Error {
-        var file = File.new_for_path ("/etc/localtime");
+        var file = File.new_for_path (TZ_FILE);
+        if (!file.query_exists ())
+            throw new Boxes.Error.INVALID ("Timezone file not found in expected location '%s'", TZ_FILE);
 
         var info = file.query_info (FileAttribute.STANDARD_SYMLINK_TARGET, 
FileQueryInfoFlags.NOFOLLOW_SYMLINKS);
         var target = info.get_symlink_target ();
+        if (target == null)
+            throw new Boxes.Error.INVALID ("Timezone file '%s' is expected to be a symlink", TZ_FILE);
+
         var tokens = target.split ("zoneinfo/");
         if (tokens == null || tokens.length < 2)
             throw new Boxes.Error.INVALID ("Timezone file in unexpected location '%s'", target);


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