protocol/ArgParser: fix integer overflow in parse_range()

Casting std::numeric_limits<unsigned>::max() to "long" leads to an
overflow if sizeof(unsigned)==sizeof(long), and the result will be -1.

This happens on some 32 bit architectures, for example ARM and WIN32.

Workaround: use std::numeric_limits<int>::max(), which is the largest
signed integer.  Since sizeof(long)>=sizeof(int), this will never
overflow.

Fixes Mantis ticket 0004080.
This commit is contained in:
Max Kellermann
2014-09-04 14:38:55 +02:00
parent 4907f610d6
commit 421c4ae907
2 changed files with 4 additions and 2 deletions

2
NEWS
View File

@@ -1,4 +1,6 @@
ver 0.18.14 (not yet released)
* protocol
- fix range parser bug on certain 32 bit architectures
ver 0.18.13 (2014/08/31)
* protocol