Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-12823

Chat cron SQL overflows integer

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 1.9
    • Fix Version/s: 1.9
    • Component/s: Chat
    • Labels:
      None
    • Environment:
      Postgres 8.1
    • Database:
      PostgreSQL
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      On line 214 of mod/chat/lib.php, there is the statement:
      ...COALESCE(($keepdays), 999999) * 24 * 3600)";...
      The coalesce select the first non-null, so if $keepdays only returns null, it selects 999999 and the number of days. This get multiplied out to seconds (86399913600), but that number is bigger than an integer in postgres, so it throws and error and that sql dies.

      A postgres int is 32 bit signed (+-2147483647), so the closest you can get it 2147483647/3600/24 = 24855.134803 ~= 24855.

      So I think that 999999 should be replaced by 24855 on that line, to keep the int from overflowing.

      -eric

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dougiamas Martin Dougiamas
              Reporter:
              emerrill Eric Merrill
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                3/Mar/08