Skip to content

Potential integer overflow in ExecutorConfigurationSupport.setAwaitTerminationSeconds(int) and AbstractResourceBasedMessageSource.setCacheSeconds(int) #25613

Closed

Description

@TomaszPierzchala

Affects: 5.2.8.RELEASE
There is a small bug in the class org.springframework.scheduling.concurrent.ExecutorConfigurationSupport
in the method :

public void setAwaitTerminationSeconds(int awaitTerminationSeconds) {
		this.awaitTerminationMillis = awaitTerminationSeconds * 1000;
}

When the input parameter awaitTerminationSeconds is bigger then Integer.MAX_VALUE/1000
the value asigned to long this.awaitTerminationMillis can even be negative !

I recommend changing the 1000 to the 1000l long version as below

public void setAwaitTerminationSeconds(int awaitTerminationSeconds) {
		this.awaitTerminationMillis = awaitTerminationSeconds * 1000l;
}

Activity

  1. changed the title [-]Bug in method : public void setAwaitTerminationSeconds(int ) of org.springframework.scheduling.concurrent.ExecutorConfigurationSupport[/-] [+]Bug in the method : public void setAwaitTerminationSeconds(int ) of org.springframework.scheduling.concurrent.ExecutorConfigurationSupport[/+] on Aug 19, 2020
  2. changed the title [-]Bug in the method : public void setAwaitTerminationSeconds(int ) of org.springframework.scheduling.concurrent.ExecutorConfigurationSupport[/-] [+]Potential integer overflow in ExecutorConfigurationSupport.setAwaitTerminationSeconds(int)[/+] on Aug 25, 2020
  3. self-assigned this
    on Aug 25, 2020
  4. added
    in: coreIssues in core modules (aop, beans, core, context, expression)
    and removed on Aug 25, 2020
  5. added this to the 5.2.9 milestone on Aug 25, 2020
  6. jhoeller commented on Aug 25, 2020

    @jhoeller
    Contributor

    Thanks for spotting this! It may be rare to specify such a large value there but it still needs to work correctly.

    This also applies to AbstractResourceBasedMessageSource.setCacheSeconds where I'll fix it the same way.

  7. added a commit that references this issue on Aug 25, 2020
    0d4040a
  8. changed the title [-]Potential integer overflow in ExecutorConfigurationSupport.setAwaitTerminationSeconds(int)[/-] [+]Potential integer overflow in ExecutorConfigurationSupport.setAwaitTerminationSeconds(int) and AbstractResourceBasedMessageSource.setCacheSeconds(int)[/+] on Aug 27, 2020
  9. added 3 commits that reference this issue on Aug 27, 2020
    f744088
    e4bf015
    6c977e9
  10. added a commit that references this issue on Sep 29, 2020
    b783041
  11. added a commit that references this issue on Feb 18, 2022
    eb8afcb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions