]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fs-randomfail: Fix failure handling for fs_read()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 22 Dec 2016 16:58:29 +0000 (11:58 -0500)
committerGitLab <gitlab@git.dovecot.net>
Fri, 23 Dec 2016 13:34:51 +0000 (15:34 +0200)
src/lib-fs/fs-randomfail.c

index ede8b313157b546f1867800f41476fe35bb198b3..f5c99deaafe3fed9b078a985e9a312bb1ffefa1c 100644 (file)
@@ -307,7 +307,9 @@ static ssize_t fs_randomfail_read(struct fs_file *_file, void *buf, size_t size)
        if (fs_file_random_fail_begin(file, FS_OP_READ))
                return -1;
        ret = fs_read(_file->parent, buf, size);
-       return fs_file_random_fail_end(file, ret, FS_OP_READ);
+       if (fs_file_random_fail_end(file, ret < 0 ? -1 : 0, FS_OP_READ) < 0)
+               return -1;
+       return ret;
 }
 
 static struct istream *