Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8341095

Possible overflow in os::Posix::print_uptime_info

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • None
    • hotspot

      In:

      void os::Posix::print_uptime_info(outputStream* st) {
        int bootsec = -1;
        time_t currsec = time(nullptr);
        struct utmpx* ent;
        setutxent();
        while ((ent = getutxent())) {
          if (!strcmp("system boot", ent->ut_line)) {
            bootsec = ent->ut_tv.tv_sec;
            break;
          }
        }

        if (bootsec != -1) {
          os::print_dhm(st, "OS uptime:", currsec-bootsec);
        }
      }

      we have:

            bootsec = ent->ut_tv.tv_sec;

      where bootsec is an int, but tv_sec is long.

            gziemski Gerard Ziemski
            gziemski Gerard Ziemski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: