summaryrefslogtreecommitdiff
path: root/src/protocol/ArgParser.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-09-04 14:38:55 +0200
committerMax Kellermann <max@duempel.org>2014-09-04 17:37:31 +0200
commit421c4ae907e27661902f28c07c1c470c3dba3cf7 (patch)
tree5dc7c244df11cdfdb7ff1a3ccdf63f02011b6095 /src/protocol/ArgParser.cxx
parent4907f610d6116949111fb6ff81c1489ec68b9d43 (diff)
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.
Diffstat (limited to 'src/protocol/ArgParser.cxx')
-rw-r--r--src/protocol/ArgParser.cxx4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/protocol/ArgParser.cxx b/src/protocol/ArgParser.cxx
index b13ea3f4e..86527c751 100644
--- a/src/protocol/ArgParser.cxx
+++ b/src/protocol/ArgParser.cxx
@@ -81,7 +81,7 @@ check_range(Client &client, unsigned *value_r1, unsigned *value_r2,
/* compatibility with older MPD versions: specifying
"-1" makes MPD display the whole list */
*value_r1 = 0;
- *value_r2 = std::numeric_limits<unsigned>::max();
+ *value_r2 = std::numeric_limits<int>::max();
return true;
}
@@ -108,7 +108,7 @@ check_range(Client &client, unsigned *value_r1, unsigned *value_r2,
}
if (test == test2)
- value = std::numeric_limits<unsigned>::max();
+ value = std::numeric_limits<int>::max();
if (value < 0) {
command_error(client, ACK_ERROR_ARG,