]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Don't use a time_t variable with fscanf when parsing uptime
authorTobias Brunner <tobias@strongswan.org>
Wed, 6 Feb 2013 15:35:44 +0000 (16:35 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 8 Feb 2013 10:33:13 +0000 (11:33 +0100)
Because "%u" is used as format string in the fscanf call that parses the
uptime and because the length of time_t varies on different platforms
and architectures the value was not written properly if time_t was longer
than an unsigned int and depending on how the target variable was aligned
on the stack.  Since there is no conversion specifier to properly parse a
time_t value we use the appropriate integer type instead.

src/libimcv/os_info/os_info.c

index 13374c8762747319ebc5c3ce5870b4e0e366aaa2..2c49cb01dfbcf741a8739c56d8c08a38f516fe56 100644 (file)
@@ -156,7 +156,7 @@ METHOD(os_info_t, get_uptime, time_t,
 {
        const char proc_uptime[] = "/proc/uptime";
        FILE *file;
-       time_t uptime;
+       u_int uptime;
 
        file = fopen(proc_uptime, "r");
        if (!file)