diff options
author | Max Kellermann <max@duempel.org> | 2008-11-21 16:56:10 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-11-21 16:56:10 +0100 |
commit | 7779e4133a8f4298b04c857b3fd72e45a02f61f1 (patch) | |
tree | dabe4abfbcc5448030031dd0de3e260fc668b04f | |
parent | a165ee25e8b32411d31ab63b932c7a056c37cb3b (diff) | |
download | mpd-7779e4133a8f4298b04c857b3fd72e45a02f61f1.tar.gz mpd-7779e4133a8f4298b04c857b3fd72e45a02f61f1.tar.xz mpd-7779e4133a8f4298b04c857b3fd72e45a02f61f1.zip |
input_curl: don't do temporary calculations with input_stream.offset
If someone calls seek() with an invalid (negative) offset, the curl
implementation of that method returned false, but left this invalid
offset in input_stream.offset. Move the calculation to a temporary
variable.
-rw-r--r-- | src/input_curl.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/input_curl.c b/src/input_curl.c index 7c98cad7c..09f10c3c6 100644 --- a/src/input_curl.c +++ b/src/input_curl.c @@ -569,11 +569,10 @@ input_curl_seek(struct input_stream *is, off_t offset, int whence) switch (whence) { case SEEK_SET: - is->offset = offset; break; case SEEK_CUR: - is->offset += offset; + offset += is->offset; break; case SEEK_END: @@ -581,20 +580,21 @@ input_curl_seek(struct input_stream *is, off_t offset, int whence) /* stream size is not known */ return false; - is->offset = is->size + offset; + offset += is->size; break; default: return false; } - if (is->offset < 0) + if (offset < 0) return false; /* close the old connection and open a new one */ input_curl_easy_free(c); + is->offset = offset; if (is->offset == is->size) { /* seek to EOF: simulate empty result; avoid triggering a "416 Requested Range Not Satisfiable" |