Package: release.debian.org
Severity: normal
User: release.debian....@packages.debian.org
Usertags: unblock
X-Debbugs-Cc: led...@packages.debian.org
Control: affects -1 + src:ledger

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Please unblock package ledger


[ Reason ]

This version fixes two bugs with severity important: #1032292 and #1033552.

[ Impact ]

The first is a regression from the version in bullseye, while the
second is an old crash.

[ Tests ]

Ledger has an extensive build time test suite. I have also manually
sanity checked the new binary packages.

[ Risks ]

Ledger is a leaf package. The two patches are cherry-picked from
upstream, and the total diff is small (6 insertions , 4 deletions)

[ Checklist ]
  [x] all changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in testing

[ Other info ]

Trimmed diff of only upstream changes also attached.


unblock ledger/3.3.0-3


-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEkiyHYXwaY0SiY6fqA0U5G1WqFSEFAmQz8r8ACgkQA0U5G1Wq
FSEE3Q//cNItCQC0KvUyWw0kY4v0aa05Y3K+F+F3u8IOBjnhGkBA5+gR4Rq110dE
4N0K7l7JLemR7eJBHtOh+LfGI6AmLGurD0hmAwVrjYC+ti5xcnDMN7tpfXLKaqIS
jmCATrWtKN9+IZKl6G4V0R7o+HtKfHb4qG8Gzk3qwvjCtTvEGJGiwA1ErwCjUidn
+uBlIzn3MRiAjxrNWUQqq8RkPtyvP95JSgvpAXtQuo0qI2YQ0/613wlS2Fq4S1+J
mlC1rr/gpLl2wpxpUGVB8ph6rsgcKs5TY8GQ5nCk8h8EfH8eAvNwrs6AKEdVna+z
TC31HQ5Jw4s7jyoQRu2L2K3lM0F97FO8P5DXA2nn+AjfQqNvBXyXZMFtLfdnWKIc
g2mws+mD0/zVUwUJtTAdeei46SJilGDJXZ9To7I0LxYcFRPvP8CGfJP0wTSNdvAU
ylEmIppHnJ/Byz5N/JgPg/oi/ehwgixmt6j9Z/2r0CwSTdBqXiEe9Qu9XjEuqT2I
O6okdg8t07zGyf2+wSyeh6cJ7x87od2OtRZi48N2yrD+t8/sPuo6TvdxZmp+LIgg
AqDvkCiQ2uCnEFg3B6shARL51Jp2UScPLnXdVH6sjSQ0QwwaHzopZ2G+nCVYG7mc
uRFlbIq9yWHGQY5oYLXDvUs+kuB98BPZOR17CYh6h3ZKvywGNmc=
=dJ3v
-----END PGP SIGNATURE-----
diff -Nru ledger-3.3.0/debian/changelog ledger-3.3.0/debian/changelog
--- ledger-3.3.0/debian/changelog       2023-02-17 09:58:07.000000000 -0400
+++ ledger-3.3.0/debian/changelog       2023-03-28 08:05:17.000000000 -0300
@@ -1,3 +1,18 @@
+ledger (3.3.0-3) unstable; urgency=medium
+
+  * Bug fix: "Valid transaction: Error: Divide by zero", thanks to Martin
+    Michlmayr (Closes: #1033552). Cherry-pick upstream commit 49cf332.
+
+ -- David Bremner <brem...@debian.org>  Tue, 28 Mar 2023 08:05:17 -0300
+
+ledger (3.3.0-2) unstable; urgency=medium
+
+  * Bug fix: "Ledger 3.3.0 regression: specifying format for commodity",
+    thanks to Martin Michlmayr (Closes: #1032292). Cherry-pick upstream
+    commit 87b6a1e.
+
+ -- David Bremner <brem...@debian.org>  Sat, 04 Mar 2023 15:32:33 -0800
+
 ledger (3.3.0-1) unstable; urgency=medium
 
   * Bug fix: "New upstream release: 3.3.0", thanks to Martin Michlmayr
diff -Nru 
ledger-3.3.0/debian/patches/0001-Do-not-perform-commodity-reduction-when-parsing-a-fo.patch
 
ledger-3.3.0/debian/patches/0001-Do-not-perform-commodity-reduction-when-parsing-a-fo.patch
--- 
ledger-3.3.0/debian/patches/0001-Do-not-perform-commodity-reduction-when-parsing-a-fo.patch
 1969-12-31 20:00:00.000000000 -0400
+++ 
ledger-3.3.0/debian/patches/0001-Do-not-perform-commodity-reduction-when-parsing-a-fo.patch
 2023-03-28 08:05:17.000000000 -0300
@@ -0,0 +1,28 @@
+From: John Wiegley <jo...@newartisans.com>
+Date: Thu, 2 Mar 2023 15:04:29 -0800
+Subject: Do not perform commodity reduction when parsing a format directive
+
+---
+ src/textual.cc | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/src/textual.cc b/src/textual.cc
+index 62007ab..5276c92 100644
+--- a/src/textual.cc
++++ b/src/textual.cc
+@@ -1132,10 +1132,12 @@ void 
instance_t::commodity_format_directive(commodity_t& comm, string format)
+   // observational formatting.
+   trim(format);
+   amount_t amt;
+-  amt.parse(format);
++  amt.parse(format, PARSE_NO_REDUCE);
+   if (amt.commodity() != comm)
+-    throw_(parse_error, _f("commodity directive symbol %1% and format 
directive symbol %2% should be the same") %
+-      comm.symbol() % amt.commodity().symbol());
++    throw_(parse_error,
++           _f("commodity directive symbol %1% and format directive symbol %2% 
should be the same")
++             % comm.symbol()
++             % amt.commodity().symbol());
+   amt.commodity().add_flags(COMMODITY_STYLE_NO_MIGRATE);
+   VERIFY(amt.valid());
+ }
diff -Nru 
ledger-3.3.0/debian/patches/0002-Change-a-use-of-is_realzero-to-just-is_zero.patch
 
ledger-3.3.0/debian/patches/0002-Change-a-use-of-is_realzero-to-just-is_zero.patch
--- 
ledger-3.3.0/debian/patches/0002-Change-a-use-of-is_realzero-to-just-is_zero.patch
  1969-12-31 20:00:00.000000000 -0400
+++ 
ledger-3.3.0/debian/patches/0002-Change-a-use-of-is_realzero-to-just-is_zero.patch
  2023-03-28 08:05:17.000000000 -0300
@@ -0,0 +1,22 @@
+From: John Wiegley <jo...@newartisans.com>
+Date: Thu, 23 Mar 2023 11:23:39 -0700
+Subject: Change a use of is_realzero to just is_zero
+
+This is needed to avoid a possible divide by zero.
+---
+ src/pool.cc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/pool.cc b/src/pool.cc
+index 2c055d6..73e7664 100644
+--- a/src/pool.cc
++++ b/src/pool.cc
+@@ -257,7 +257,7 @@ commodity_pool_t::exchange(const amount_t&             
amount,
+     current_annotation = &as_annotated_commodity(commodity).details;
+ 
+   amount_t per_unit_cost =
+-    (is_per_unit || amount.is_realzero()) ? cost.abs() : (cost / 
amount).abs();
++    (is_per_unit || amount.is_zero()) ? cost.abs() : (cost / amount).abs();
+ 
+   if (! cost.has_commodity())
+     per_unit_cost.clear_commodity();
diff -Nru ledger-3.3.0/debian/patches/series ledger-3.3.0/debian/patches/series
--- ledger-3.3.0/debian/patches/series  1969-12-31 20:00:00.000000000 -0400
+++ ledger-3.3.0/debian/patches/series  2023-03-28 08:05:17.000000000 -0300
@@ -0,0 +1,2 @@
+0001-Do-not-perform-commodity-reduction-when-parsing-a-fo.patch
+0002-Change-a-use-of-is_realzero-to-just-is_zero.patch
diff --git a/src/pool.cc b/src/pool.cc
index 2c055d64..73e76644 100644
--- a/src/pool.cc
+++ b/src/pool.cc
@@ -257,7 +257,7 @@ commodity_pool_t::exchange(const amount_t&             
amount,
     current_annotation = &as_annotated_commodity(commodity).details;
 
   amount_t per_unit_cost =
-    (is_per_unit || amount.is_realzero()) ? cost.abs() : (cost / amount).abs();
+    (is_per_unit || amount.is_zero()) ? cost.abs() : (cost / amount).abs();
 
   if (! cost.has_commodity())
     per_unit_cost.clear_commodity();
diff --git a/src/textual.cc b/src/textual.cc
index 62007abb..5276c92b 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -1132,10 +1132,12 @@ void 
instance_t::commodity_format_directive(commodity_t& comm, string format)
   // observational formatting.
   trim(format);
   amount_t amt;
-  amt.parse(format);
+  amt.parse(format, PARSE_NO_REDUCE);
   if (amt.commodity() != comm)
-    throw_(parse_error, _f("commodity directive symbol %1% and format 
directive symbol %2% should be the same") %
-       comm.symbol() % amt.commodity().symbol());
+    throw_(parse_error,
+           _f("commodity directive symbol %1% and format directive symbol %2% 
should be the same")
+             % comm.symbol()
+             % amt.commodity().symbol());
   amt.commodity().add_flags(COMMODITY_STYLE_NO_MIGRATE);
   VERIFY(amt.valid());
 }

Reply via email to