summaryrefslogtreecommitdiffstats
path: root/stream/stream_smb.c
diff options
context:
space:
mode:
authorYclept Nemo <pscjtwjdjtAhnbjm/dpn>2018-06-23 11:09:26 -0400
committerJan Ekström <jeebjp@gmail.com>2018-07-29 12:59:03 +0300
commit0914da082f3a034d9b2d2524d4bc3067555d95d7 (patch)
tree15db507b0bafd2013f68abddb519296b721e7eff /stream/stream_smb.c
parent021bea159215347e7f3aaae6b87bcd83a3313cf2 (diff)
downloadmpv-0914da082f3a034d9b2d2524d4bc3067555d95d7.tar.bz2
mpv-0914da082f3a034d9b2d2524d4bc3067555d95d7.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_smb.c')
-rw-r--r--stream/stream_smb.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/stream/stream_smb.c b/stream/stream_smb.c
index 822ffdbfb0..269974f18b 100644
--- a/stream/stream_smb.c
+++ b/stream/stream_smb.c
@@ -84,18 +84,18 @@ 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) {
+ int r = len;
+ int wr;
+ while (r > 0) {
pthread_mutex_lock(&smb_lock);
- r = smbc_write(p->fd,buffer,len);
+ wr = smbc_write(p->fd,buffer,r);
pthread_mutex_unlock(&smb_lock);
- if (r <= 0)
+ if (wr <= 0)
return -1;
- wr += r;
- buffer += r;
+ r -= wr;
+ buffer += wr;
}
- return len;
+ return len - r;
}
static void close_f(stream_t *s){