From ba6984504e8ccc120335e722a6f04bfaace47f2d Mon Sep 17 00:00:00 2001 From: Heinz Mauelshagen Date: Tue, 13 Mar 2012 12:15:32 +0100 Subject: [PATCH 1/3] Fix segfault with file argument --- metadata.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.cc b/metadata.cc index 8de2974..d473c17 100644 --- a/metadata.cc +++ b/metadata.cc @@ -66,7 +66,7 @@ namespace { throw runtime_error("Couldn't stat dev path"); if (S_ISREG(info.st_mode)) - nr_blocks = div_down(info.st_size, MD_BLOCK_SIZE); + nr_blocks = div_up(info.st_size, MD_BLOCK_SIZE); else if (S_ISBLK(info.st_mode)) { // To get the size of a block device we need to From ef7e3b7e9412043ff0e2363be55cc5c976491705 Mon Sep 17 00:00:00 2001 From: Heinz Mauelshagen Date: Tue, 13 Mar 2012 12:26:35 +0100 Subject: [PATCH 2/3] Catch bz802242 artifical zero size file segfault --- metadata.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.cc b/metadata.cc index d473c17..a7da4b9 100644 --- a/metadata.cc +++ b/metadata.cc @@ -65,7 +65,7 @@ namespace { if (r) throw runtime_error("Couldn't stat dev path"); - if (S_ISREG(info.st_mode)) + if (S_ISREG(info.st_mode) && info.st_size) nr_blocks = div_up(info.st_size, MD_BLOCK_SIZE); else if (S_ISBLK(info.st_mode)) { From 212d8417b299532d5fac3048e053cfb4bad83974 Mon Sep 17 00:00:00 2001 From: Heinz Mauelshagen Date: Tue, 13 Mar 2012 13:10:13 +0100 Subject: [PATCH 3/3] thin_check: add missing LF --- thin_check.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thin_check.cc b/thin_check.cc index fdc09d6..ff2b3da 100644 --- a/thin_check.cc +++ b/thin_check.cc @@ -41,7 +41,7 @@ namespace { } } catch (std::exception &e) { if (!quiet) - cerr << e.what(); + cerr << e.what() << endl; return 1; }