Uploaded image for project: 'Blesta Core'
  1. Blesta Core
  2. CORE-4661

Potential division by 0 in a few modules

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.5.2
    • Component/s: None
    • Labels:
      None

      Description

      There are a few control panels with this issue

      • APISCP
      • CentovaCast
      • cPanel
      • Plesk

      It appears in each in the tab_client_stats.pdt view file. The lines look something like this

          $percent_used = ($unlimited ? 0 : round(((isset($disk['used']) ? $disk['used'] : 0)/(isset($disk['limit']) ? $disk['limit'] : null))*100, 0));
          $percent_used = ($unlimited ? 0 : round(((isset($bandwidth['used']) ? $bandwidth['used'] : 0)/(isset($bandwidth['limit']) ? $bandwidth['limit'] : null))*100, 0));
      

      But $bandwidth['limit'] and $disk['limit'] can technically be 0 and null is no a valid default for the ternary. We should use min(..., 1) to ensure a valid division.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            abdy Abdy Franco
            Reporter:
            jonathan Jonathan Reissmueller
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Fix Release Date:
              20/Sep/22

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 3 hours, 33 minutes
              3h 33m

                Agile