diff options
author | David Sterba <dsterba@suse.cz> | 2013-07-09 18:39:24 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2013-08-09 14:32:35 +0200 |
commit | a8c9a2087a81c291e6a8a844fd2aaea561f64f1f (patch) | |
tree | bbaf8ba32c0d27a216faeab33f4e94e8f43a6e1d /cmds-subvolume.c | |
parent | 82ddde496a3c10e4f48363c578c9c2510d3a48e7 (diff) |
btrfs-progs: use reentrant localtime
localtime may return NULL (when an error is detected eg. after setting
tzname), followed by a segfault when the values is about to be used.
localtime_r works, does not set tzname and does not return NULL.
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'cmds-subvolume.c')
-rw-r--r-- | cmds-subvolume.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/cmds-subvolume.c b/cmds-subvolume.c index 9db989eb..67ff8a51 100644 --- a/cmds-subvolume.c +++ b/cmds-subvolume.c @@ -908,10 +908,12 @@ static int cmd_subvol_show(int argc, char **argv) uuid_unparse(get_ri.puuid, uuidparse); printf("\tParent uuid: \t\t%s\n", uuidparse); - if (get_ri.otime) - strftime(tstr, 256, "%Y-%m-%d %X", - localtime(&get_ri.otime)); - else + if (get_ri.otime) { + struct tm tm; + + localtime_r(&get_ri.otime, &tm); + strftime(tstr, 256, "%Y-%m-%d %X", &tm); + } else strcpy(tstr, "-"); printf("\tCreation time: \t\t%s\n", tstr); |