diff options
author | Yclept Nemo <pscjtwjdjtAhnbjm/dpn> | 2018-06-23 11:09:26 -0400 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2018-07-29 12:54:56 +0300 |
commit | 5532a3da1ee058443d3162582b601f19b59377c2 (patch) | |
tree | 8ecb20ebb23982cd563dc4a4fdbe512a2c3bb51b /stream/stream_file.c | |
parent | 112b3fa92266ab36dbffa2abf66034203f66b2ce (diff) | |
download | mpv-5532a3da1ee058443d3162582b601f19b59377c2.tar.bz2 mpv-5532a3da1ee058443d3162582b601f19b59377c2.tar.xz |
stream_smb/stream_file: fix `write_buffer`
Functions `write` and `smbc_write` are given a diminishing buffer of
incorrect constant size. After partial writes, the code would do another
write of the full original length, failing to subtract the amount
already written.
Diffstat (limited to 'stream/stream_file.c')
-rw-r--r-- | stream/stream_file.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/stream/stream_file.c b/stream/stream_file.c index 5cf63558f2..a905780b2d 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -121,16 +121,16 @@ static int fill_buffer(stream_t *s, char *buffer, int max_len) static int write_buffer(stream_t *s, char *buffer, int len) { struct priv *p = s->priv; - int r; - int wr = 0; - while (wr < len) { - r = write(p->fd, buffer, len); - if (r <= 0) + int r = len; + int wr; + while (r > 0) { + wr = write(p->fd, buffer, r); + if (wr <= 0) return -1; - wr += r; - buffer += r; + r -= wr; + buffer += wr; } - return len; + return len - r; } static int seek(stream_t *s, int64_t newpos) |