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

        jonathan Jonathan Reissmueller created issue -
        jonathan Jonathan Reissmueller made changes -
        Field Original Value New Value
        Rank Ranked higher
        jonathan Jonathan Reissmueller made changes -
        Fix Version/s 5.6.0-b1 [ 11730 ]
        Fix Version/s Short Term [ 10800 ]
        jonathan Jonathan Reissmueller made changes -
        Priority Major [ 3 ] Minor [ 4 ]
        jonathan Jonathan Reissmueller made changes -
        Sprint 5.6.0 Sprint 2 [ 158 ]
        jonathan Jonathan Reissmueller made changes -
        Rank Ranked lower
        jonathan Jonathan Reissmueller made changes -
        Sprint 5.6.0 Sprint 3 [ 158 ] 5.6.0 Sprint 2 [ 167 ]
        jonathan Jonathan Reissmueller made changes -
        Rank Ranked higher
        jonathan Jonathan Reissmueller made changes -
        Fix Version/s 5.5.2 [ 11736 ]
        Fix Version/s 5.6.0-b1 [ 11730 ]
        abdy Abdy Franco made changes -
        Assignee Abdy Franco [ abdy ]
        abdy Abdy Franco made changes -
        Remaining Estimate 0 minutes [ 0 ]
        Time Spent 1 hour, 32 minutes [ 5520 ]
        Worklog Id 15954 [ 15954 ]
        abdy Abdy Franco made changes -
        Time Spent 1 hour, 32 minutes [ 5520 ] 3 hours, 33 minutes [ 12780 ]
        Worklog Id 15955 [ 15955 ]
        abdy Abdy Franco made changes -
        Status Open [ 1 ] In Review [ 5 ]
        Resolution Fixed [ 1 ]
        jonathan Jonathan Reissmueller made changes -
        Status In Review [ 5 ] Closed [ 6 ]

          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