Changeset 52b44c6 in mainline


Ignore:
Timestamp:
2019-02-23T23:01:31Z (5 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0c48e14, ee8d4d6
Parents:
ca0e838
git-author:
Wang Jianjian <wangjianjian3@…> (2019-02-23 06:20:33)
git-committer:
Jakub Jermar <jakub@…> (2019-02-23 23:01:31)
Message:

srv/vfs: return after checking old fd's validity

It's possible for a user to call vfs_clone with invalid fds,
both the old and new ones when they are same. And if it's the case,
we should check its validity or user maybe got a invalid one.

Signed-off-by: Wang Jianjian <wangjianjian3@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs_ops.c

    rca0e838 r52b44c6  
    9090        errno_t rc;
    9191
    92         /* If the file descriptors are the same, do nothing. */
    93         if (oldfd == newfd)
    94                 return EOK;
    95 
    9692        /* Lookup the file structure corresponding to fd. */
    9793        vfs_file_t *oldfile = vfs_file_get(oldfd);
     
    10096
    10197        assert(oldfile->node != NULL);
     98
     99        /* If the file descriptors are the same, do nothing. */
     100        if (oldfd == newfd) {
     101                vfs_file_put(oldfile);
     102                return EOK;
     103        }
    102104
    103105        if (newfd != -1) {
Note: See TracChangeset for help on using the changeset viewer.