[chrony-dev] [sdl-chrony] NO_CAST.INTEGER_OVERFLOW in set_frequency function

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]


Dear colleagues!

While analyzing the program code, we found the following: NO_CAST.INTEGER_OVERFLOW in sys_linux.c .

The value of an arithmetic _expression_ 'nominal_tick - required_delta_tick' is a subject to overflow because its operands are not cast to a larger data type before perfoming arithmetic:

 
Both nominal_tick and required_delta_tick have an int type, but required_tick has a long type.

This means that we get this code:

```
  int x = -2147483648;
  int y = -20;
  long int z = x + y; //2147483628
```

when expect this one:

```
  int x = -2147483648;
  int y = -20;
  long int z = (long)x + y; //-2147483668
```


Found by Linux Verification Center portal.linuxtesting.ru with SVACE.

Author E. Bykhanova.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/