Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-2748

TimeSlice and Socket-Timeout bounds checking wrong

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 10.2.2.0
    • 10.3.1.4
    • Network Client
    • None

    Description

      ClientThread sets the Socket timeout based upon the timeslice value:

      //set time out
      //this looks highly suspect. Why does timeSlice setSoTimeout?
      if (timeSlice != 0)
      clientSocket.setSoTimeout(timeSlice);

      it gets the timeSlice from NetworkServerControlImpl which sets it like this:

      /**

      • Set the current value of time slice
        *
      • @param value time slice value
      • @exception Exception if value is < 0
        */
        private void setTimeSlice(int value)
        throws Exception
        Unknown macro: { if (value < MIN_TIMESLICE) consolePropertyMessage("DRDA_InvalidValue.U", new String [] {new Integer(value).toString(), "timeslice"}); if (value == USE_DEFAULT) value = DEFAULT_TIMESLICE; synchronized(timeSliceSync) { timeSlice = value; } }

      but

      private final static int MIN_TIMESLICE = -1;

      therefore a value of -1 is accepted by setTimeSlice, due to "!= 0" used for Socket.setSoTimeout which will bail out with an Exception:

      if (timeout < 0)
      throw new IllegalArgumentException("timeout can't be negative");

      According to the comments, the proper fix would be

      • private final static int MIN_TIMESLICE = -1;
        + private final static int MIN_TIMESLICE = 0;

      but I do not understand the timeslice at all, so this is just my guess.

      Attachments

        1. DERBY-2748-code.diff
          0.7 kB
          Bernt Johnsen
        2. DERBY-2748-code-v2.diff
          1 kB
          Bernt Johnsen
        3. DERBY-2748-code-v2.stat
          0.1 kB
          Bernt Johnsen
        4. DERBY-2748-doc.diff
          0.9 kB
          Bernt Johnsen

        Activity

          People

            bernt Bernt Johnsen
            kurti Kurt Huwig
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: