Merge pull request #207 from giuseppe/static-analysis

fuse-overlayfs: fix different issues reported by static analysis
This commit is contained in:
Daniel J Walsh 2020-05-04 08:02:22 -04:00 committed by GitHub
commit d2c9645000
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 26 deletions

View File

@ -44,6 +44,6 @@ script:
- (cd /unionmount-testsuite; sudo FUSE_OVERLAYFS_DISABLE_OVL_WHITEOUT=1 unshare -m ./run --ov --fuse=fuse-overlayfs --xdev) || travis_terminate 1;
- sudo tests/fedora-installs.sh || travis_terminate 1;
- sudo tests/unlink.sh || travis_terminate 1;
- (cd $GOPATH/src/github.com/containers/storage/tests; sudo STORAGE_OPTION=overlay.mount_program=/sbin/fuse-overlayfs STORAGE_DRIVER=overlay unshare -m ./test_runner.bash) || travis_terminate 1;
- (cd $GOPATH/src/github.com/containers/storage/tests; sudo FUSE_OVERLAYFS_DISABLE_OVL_WHITEOUT=1 STORAGE_OPTION=overlay.mount_program=/sbin/fuse-overlayfs STORAGE_DRIVER=overlay unshare -m ./test_runner.bash) || travis_terminate 1;
- (cd $GOPATH/src/github.com/containers/storage/tests; sudo JOBS=1 STORAGE_OPTION=overlay.mount_program=/sbin/fuse-overlayfs STORAGE_DRIVER=overlay unshare -m ./test_runner.bash) || travis_terminate 1;
- (cd $GOPATH/src/github.com/containers/storage/tests; sudo JOBS=1 FUSE_OVERLAYFS_DISABLE_OVL_WHITEOUT=1 STORAGE_OPTION=overlay.mount_program=/sbin/fuse-overlayfs STORAGE_DRIVER=overlay unshare -m ./test_runner.bash) || travis_terminate 1;
- docker run --rm -v $(pwd):/fuse-overlayfs alpine-build sh -c 'cd /fuse-overlayfs; ./autogen.sh && ./configure && make clean && make'

37
main.c
View File

@ -1097,19 +1097,13 @@ make_whiteout_node (const char *path, const char *name)
new_name = strdup (name);
if (new_name == NULL)
{
free (ret);
return NULL;
}
return NULL;
node_set_name (ret, new_name);
ret->path = strdup (path);
if (ret->path == NULL)
{
free (new_name);
free (ret);
return NULL;
}
return NULL;
ret->whiteout = 1;
ret->ino = &dummy_ino;
@ -1225,7 +1219,6 @@ make_ovl_node (struct ovl_data *lo, const char *path, struct ovl_layer *layer, c
for (it = layer; it; it = it->next)
{
ssize_t s;
bool stat_only = false;
cleanup_free char *val = NULL;
cleanup_free char *origin = NULL;
cleanup_close int fd = -1;
@ -1275,12 +1268,6 @@ make_ovl_node (struct ovl_data *lo, const char *path, struct ovl_layer *layer, c
ret->last_layer = it;
}
if (stat_only)
{
has_origin = false;
goto no_fd;
}
s = safe_read_xattr (&val, fd, PRIVILEGED_ORIGIN_XATTR, PATH_MAX);
if (s > 0)
{
@ -1766,7 +1753,7 @@ do_lookup_file (struct ovl_data *lo, fuse_ino_t parent, const char *name)
char whpath[PATH_MAX];
const char *wh_name;
if (pnode && pnode->last_layer == it)
if (pnode->last_layer == it)
stop_lookup = true;
strconcat3 (path, PATH_MAX, pnode->path, "/", name);
@ -2570,12 +2557,14 @@ copy_fd_to_fd (int sfd, int dfd, char *buf, size_t buf_size)
break;
written = 0;
{
ret = TEMP_FAILURE_RETRY (write (dfd, buf + written, nread));
if (ret < 0)
return ret;
nread -= ret;
}
do
{
ret = TEMP_FAILURE_RETRY (write (dfd, buf + written, nread));
if (ret < 0)
return ret;
nread -= ret;
written += ret;
}
while (nread);
}
return 0;
@ -4707,7 +4696,7 @@ direct_ioctl (struct ovl_layer *l, int fd, int cmd, unsigned long *r)
}
static void
ovl_ioctl (fuse_req_t req, fuse_ino_t ino, unsigned int cmd, void *arg,
ovl_ioctl (fuse_req_t req, fuse_ino_t ino, int cmd, void *arg,
struct fuse_file_info *fi, unsigned int flags,
const void *in_buf, size_t in_bufsz, size_t out_bufsz)
{

View File

@ -1,5 +1,7 @@
#!/bin/sh
rm -rf lower upper workdir merged
mkdir lower upper workdir merged
touch lower/a