guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch core-updates updated: status: Guard against a numerical overflow


From: guix-commits
Subject: branch core-updates updated: status: Guard against a numerical overflow condition.
Date: Mon, 10 Apr 2023 22:20:08 -0400

This is an automated email from the git hooks/post-receive script.

apteryx pushed a commit to branch core-updates
in repository guix.

The following commit(s) were added to refs/heads/core-updates by this push:
     new 3bc9082523 status: Guard against a numerical overflow condition.
3bc9082523 is described below

commit 3bc90825239bc1db6ea3e7dc88e3f8d4e6b2bdaf
Author: Maxim Cournoyer <maxim.cournoyer@gmail.com>
AuthorDate: Mon Apr 10 22:08:09 2023 -0400

    status: Guard against a numerical overflow condition.
    
    Fixes <https://issues.guix.gnu.org/62766>.
    
    * guix/status.scm (update-build): Use 0 as progress when an exception occurs
    while computing it.
---
 guix/status.scm | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/guix/status.scm b/guix/status.scm
index d4d3fca026..fd89ba9dd3 100644
--- a/guix/status.scm
+++ b/guix/status.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017-2023 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -190,9 +191,17 @@ a completion indication."
         ((regexp-exec %fraction-line-rx line)
          =>
          (lambda (match)
-           (let ((done  (string->number (match:substring match 1)))
-                 (total (string->number (match:substring match 3))))
-             (update (* 100. (/ done total))))))
+           (let* ((done  (string->number (match:substring match 1)))
+                  (total (string->number (match:substring match 3)))
+                  ;; It's possible that both done and total are 0 (see:
+                  ;; https://issues.guix.gnu.org/62766).  Special case this
+                  ;; pathological case as a null progress (0).
+                  (progress (catch 'numerical-overflow
+                              (lambda ()
+                                (/ done total))
+                              (lambda _
+                                0))))
+             (update (* 100. progress)))))
         ((regexp-exec %phase-start-rx line)
          =>
          (lambda (match)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]