]> code.ossystems Code Review - openembedded-core.git/blob
2452f7e08e7e8326a24c91f2ca037ba6a6873e6a
[openembedded-core.git] /
1 From 3593063f735f453d43f461292e26913436c11ca3 Mon Sep 17 00:00:00 2001
2 From: Alexander Kanavin <alex.kanavin@gmail.com>
3 Date: Sat, 1 May 2021 13:06:12 +0200
4 Subject: [PATCH] lib/ext2fs/unix_io.c: revert parts of "libext2fs: fix
5  potential races in unix_io"
6
7 Upstream-Status: Submitted [https://github.com/tytso/e2fsprogs/pull/68]
8 Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
9 ---
10  lib/ext2fs/unix_io.c | 15 ++++++++-------
11  1 file changed, 8 insertions(+), 7 deletions(-)
12
13 diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
14 index 528c2fbc..f4916b21 100644
15 --- a/lib/ext2fs/unix_io.c
16 +++ b/lib/ext2fs/unix_io.c
17 @@ -311,10 +311,10 @@ bounce_read:
18                         size += really_read;
19                         goto short_read;
20                 }
21 -               actual = size;
22 -               if (actual > align_size)
23 -                       actual = align_size;
24 -               actual -= offset;
25 +               if ((actual + offset) > align_size)
26 +                       actual = align_size - offset;
27 +               if (actual > size)
28 +                       actual = size;
29                 memcpy(buf, data->bounce + offset, actual);
30  
31                 really_read += actual;
32 @@ -455,9 +455,10 @@ bounce_write:
33                         }
34                 }
35                 actual = size;
36 -               if (actual > align_size)
37 -                       actual = align_size;
38 -               actual -= offset;
39 +               if ((actual + offset) > align_size)
40 +                       actual = align_size - offset;
41 +               if (actual > size)
42 +                       actual = size;
43                 memcpy(((char *)data->bounce) + offset, buf, actual);
44                 if (ext2fs_llseek(data->dev, aligned_blk * align_size, SEEK_SET) < 0) {
45                         retval = errno ? errno : EXT2_ET_LLSEEK_FAILED;
46 -- 
47 2.24.0
48