server: Don't crash when trying to set a file lock on a device.

This commit is contained in:
Alexandre Julliard 2007-06-20 13:14:55 +02:00
parent 332d14953b
commit 60901b7542
2 changed files with 7 additions and 6 deletions

View File

@ -1184,12 +1184,6 @@ static struct file_lock *add_lock( struct fd *fd, int shared, file_pos_t start,
{
struct file_lock *lock;
if (!fd->inode) /* not a regular file */
{
set_error( STATUS_INVALID_HANDLE );
return NULL;
}
if (!(lock = alloc_object( &file_lock_ops ))) return NULL;
lock->shared = shared;
lock->start = start;
@ -1259,6 +1253,12 @@ obj_handle_t lock_fd( struct fd *fd, file_pos_t start, file_pos_t count, int sha
struct list *ptr;
file_pos_t end = start + count;
if (!fd->inode) /* not a regular file */
{
set_error( STATUS_INVALID_DEVICE_REQUEST );
return 0;
}
/* don't allow wrapping locks */
if (end && end < start)
{

View File

@ -4246,6 +4246,7 @@ static const struct
{ "ILLEGAL_FUNCTION", STATUS_ILLEGAL_FUNCTION },
{ "INSTANCE_NOT_AVAILABLE", STATUS_INSTANCE_NOT_AVAILABLE },
{ "INVALID_CID", STATUS_INVALID_CID },
{ "INVALID_DEVICE_REQUEST", STATUS_INVALID_DEVICE_REQUEST },
{ "INVALID_FILE_FOR_SECTION", STATUS_INVALID_FILE_FOR_SECTION },
{ "INVALID_HANDLE", STATUS_INVALID_HANDLE },
{ "INVALID_PARAMETER", STATUS_INVALID_PARAMETER },