]> git.ipfire.org Git - thirdparty/lxc.git/commit
lseek - integer overflow 2545/head
authorLukasz Jagiello <lukasz@wikia-inc.com>
Sat, 18 Aug 2018 15:32:21 +0000 (08:32 -0700)
committerLukasz Jagiello <lukasz@wikia-inc.com>
Sat, 18 Aug 2018 15:32:21 +0000 (08:32 -0700)
commit8737e2a8a56f2dc4c8f35ccc413d59b5c78c3a30
tree5311f04bbb35f9fd100209e2b3e79e7a1fd5db3b
parent5493a1bf8994c54071ce25e995faecc0c06a8ee1
lseek - integer overflow

The issue was introduced in PR (https://github.com/lxc/lxc/pull/1705):

Previous code:
```
  if (lseek(fd, size, SEEK_SET) < 0) {
    SYSERROR("Error seeking to set new loop file size");
    close(fd);
    return -1;
  }
```
New code:
```
  int fd, ret;

  [...]

  ret = lseek(fd, size, SEEK_SET);
  if (ret < 0) {
    SYSERROR("Failed to seek to set new loop file size for loop "
       "file \"%s\"", path);
    close(fd);
    return -1;
  }
```

Based on http://man7.org/linux/man-pages/man2/lseek.2.html:
> Upon successful completion, lseek() returns the resulting offset
> location as measured in bytes from the beginning of the file.

So in this case value of `size` and `size` is `uint64_t`.

This fix change declaration of `ret`, but it can be fixed in other ways.
Let me know what works for you.

This PR fix issues (https://github.com/lxc/lxc/issues/1872).

Signed-off-by: Lukasz Jagiello <lukasz@wikia-inc.com>
src/lxc/storage/loop.c