btrfsprogs/0053-btrfs-progs-use-reentrant-localtime.patch
Tomáš Chvátal 5be20c4ea7 Accepting request 205320 from home:dsterba:branches:filesystems
SR: a few fixes, aimed for 13.1 RC2

- fsck updates
- more mkfs sanity checks
- qgroup rescan wait

OBS-URL: https://build.opensuse.org/request/show/205320
OBS-URL: https://build.opensuse.org/package/show/filesystems/btrfsprogs?expand=0&rev=144
2013-10-31 09:12:04 +00:00

62 lines
1.8 KiB
Diff

From 2fac6f99128560c5993a02d2de0cc3d8238f3b51 Mon Sep 17 00:00:00 2001
From: David Sterba <dsterba@suse.cz>
Date: Tue, 9 Jul 2013 18:39:24 +0200
Subject: [PATCH 53/62] 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>
---
btrfs-list.c | 10 ++++++----
cmds-subvolume.c | 10 ++++++----
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/btrfs-list.c b/btrfs-list.c
index 4fab85882165..ea80bfeef2f1 100644
--- a/btrfs-list.c
+++ b/btrfs-list.c
@@ -1337,10 +1337,12 @@ static void print_subvolume_column(struct root_info *subv,
printf("%llu", subv->top_id);
break;
case BTRFS_LIST_OTIME:
- if (subv->otime)
- strftime(tstr, 256, "%Y-%m-%d %X",
- localtime(&subv->otime));
- else
+ if (subv->otime) {
+ struct tm tm;
+
+ localtime_r(&subv->otime, &tm);
+ strftime(tstr, 256, "%Y-%m-%d %X", &tm);
+ } else
strcpy(tstr, "-");
printf("%s", tstr);
break;
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index ccb476274240..faf05cab2ad9 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -898,10 +898,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);
--
1.8.3.1