aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>2012-02-15 20:35:06 +0100
committerJonathan Neuschäfer <j.neuschaefer@gmx.net>2012-02-15 20:35:06 +0100
commitd22df2915ce5005e6789f0cd4d188e56432264a7 (patch)
treeec48fd98305583666b7abb16359061590554f925 /src
parente77d96cf892592f299d6b09955db1b852b2234b3 (diff)
downloadmpd-d22df2915ce5005e6789f0cd4d188e56432264a7.tar.gz
mpd-d22df2915ce5005e6789f0cd4d188e56432264a7.tar.xz
mpd-d22df2915ce5005e6789f0cd4d188e56432264a7.zip
main: handle negative strtol return value
size_t is unsigned most of the time, so we can't really use it to check for negative values. Also handle strtol overflow.
Diffstat (limited to '')
-rw-r--r--src/main.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index f7e7ba778..687e86f7e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -258,10 +258,11 @@ initialize_decoder_and_player(void)
param = config_get_param(CONF_AUDIO_BUFFER_SIZE);
if (param != NULL) {
- buffer_size = strtol(param->value, &test, 10);
- if (*test != '\0' || buffer_size <= 0)
+ long tmp = strtol(param->value, &test, 10);
+ if (*test != '\0' || tmp <= 0 || tmp == LONG_MAX)
MPD_ERROR("buffer size \"%s\" is not a positive integer, "
"line %i\n", param->value, param->line);
+ buffer_size = tmp;
} else
buffer_size = DEFAULT_BUFFER_SIZE;