mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-01 10:03:24 -05:00
Fix lseek() return value handling
lseek() returns an off_t and not an int, using an int to store and test the return value means we'll error out when the position in the file gets past INT_MAX.
This commit is contained in:
parent
2b4f07195a
commit
a5a46b8a53
@ -321,6 +321,7 @@ httpd_stream_file(struct evhttp_request *req, int id)
|
|||||||
char buf[64];
|
char buf[64];
|
||||||
int64_t offset;
|
int64_t offset;
|
||||||
int64_t end_offset;
|
int64_t end_offset;
|
||||||
|
off_t pos;
|
||||||
int transcode;
|
int transcode;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -447,8 +448,8 @@ httpd_stream_file(struct evhttp_request *req, int id)
|
|||||||
}
|
}
|
||||||
st->size = sb.st_size;
|
st->size = sb.st_size;
|
||||||
|
|
||||||
ret = lseek(st->fd, offset, SEEK_SET);
|
pos = lseek(st->fd, offset, SEEK_SET);
|
||||||
if (ret < 0)
|
if (pos == (off_t) -1)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_HTTPD, "Could not seek into %s: %s\n", mfi->path, strerror(errno));
|
DPRINTF(E_LOG, L_HTTPD, "Could not seek into %s: %s\n", mfi->path, strerror(errno));
|
||||||
|
|
||||||
|
@ -313,6 +313,7 @@ struct transcode_ctx *
|
|||||||
transcode_setup(struct media_file_info *mfi, off_t *est_size)
|
transcode_setup(struct media_file_info *mfi, off_t *est_size)
|
||||||
{
|
{
|
||||||
struct transcode_ctx *ctx;
|
struct transcode_ctx *ctx;
|
||||||
|
off_t pos;
|
||||||
int hdr_len;
|
int hdr_len;
|
||||||
int i;
|
int i;
|
||||||
int ret;
|
int ret;
|
||||||
@ -428,8 +429,8 @@ transcode_setup(struct media_file_info *mfi, off_t *est_size)
|
|||||||
else
|
else
|
||||||
hdr_len = 0;
|
hdr_len = 0;
|
||||||
|
|
||||||
ret = lseek(ctx->fd, hdr_len, SEEK_SET);
|
pos = lseek(ctx->fd, hdr_len, SEEK_SET);
|
||||||
if (ret < 0)
|
if (pos == (off_t) -1)
|
||||||
{
|
{
|
||||||
DPRINTF(E_WARN, L_XCODE, "Could not seek: %s\n", strerror(errno));
|
DPRINTF(E_WARN, L_XCODE, "Could not seek: %s\n", strerror(errno));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user