better error handling in rdpdr and disk.c - partial merge of Volker Mildes patch.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@611 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
parent
7127d4eb29
commit
714cbcd099
@ -240,6 +240,7 @@ enum RDP_INPUT_DEVICE
|
|||||||
#define RDP_LOGON_NORMAL 0x33
|
#define RDP_LOGON_NORMAL 0x33
|
||||||
#define RDP_LOGON_AUTO 0x8
|
#define RDP_LOGON_AUTO 0x8
|
||||||
#define RDP_LOGON_BLOB 0x100
|
#define RDP_LOGON_BLOB 0x100
|
||||||
|
#define RDP_COMPRESSION 0x80
|
||||||
|
|
||||||
/* Keymap flags */
|
/* Keymap flags */
|
||||||
#define MapRightShiftMask (1<<0)
|
#define MapRightShiftMask (1<<0)
|
||||||
@ -326,6 +327,7 @@ enum RDP_INPUT_DEVICE
|
|||||||
#define STATUS_PENDING 0x00000103
|
#define STATUS_PENDING 0x00000103
|
||||||
#define STATUS_CANCELLED 0xc0000120
|
#define STATUS_CANCELLED 0xc0000120
|
||||||
#define STATUS_TIMEOUT 0xc0000102
|
#define STATUS_TIMEOUT 0xc0000102
|
||||||
|
#define STATUS_OBJECT_NAME_COLLISION 0xc0000035
|
||||||
|
|
||||||
/* RDPDR constants */
|
/* RDPDR constants */
|
||||||
#define RDPDR_MAX_DEVICES 0x10
|
#define RDPDR_MAX_DEVICES 0x10
|
||||||
|
13
disk.c
13
disk.c
@ -137,7 +137,6 @@ struct fileinfo
|
|||||||
}
|
}
|
||||||
g_fileinfo[MAX_OPEN_FILES];
|
g_fileinfo[MAX_OPEN_FILES];
|
||||||
|
|
||||||
|
|
||||||
time_t
|
time_t
|
||||||
get_create_time(struct stat *st)
|
get_create_time(struct stat *st)
|
||||||
{
|
{
|
||||||
@ -182,7 +181,7 @@ convert_1970_to_filetime(uint32 high, uint32 low)
|
|||||||
|
|
||||||
/* Enumeration of devices from rdesktop.c */
|
/* Enumeration of devices from rdesktop.c */
|
||||||
/* returns numer of units found and initialized. */
|
/* returns numer of units found and initialized. */
|
||||||
/* optarg looks like ':h:=/mnt/floppy,b:=/mnt/usbdevice1' */
|
/* optarg looks like ':h=/mnt/floppy,b=/mnt/usbdevice1' */
|
||||||
/* when it arrives to this function. */
|
/* when it arrives to this function. */
|
||||||
int
|
int
|
||||||
disk_enum_devices(uint32 * id, char *optarg)
|
disk_enum_devices(uint32 * id, char *optarg)
|
||||||
@ -341,6 +340,9 @@ disk_create(uint32 device_id, uint32 accessmask, uint32 sharemode, uint32 create
|
|||||||
case ENOENT:
|
case ENOENT:
|
||||||
|
|
||||||
return STATUS_NO_SUCH_FILE;
|
return STATUS_NO_SUCH_FILE;
|
||||||
|
case EEXIST:
|
||||||
|
|
||||||
|
return STATUS_OBJECT_NAME_COLLISION;
|
||||||
default:
|
default:
|
||||||
|
|
||||||
perror("open");
|
perror("open");
|
||||||
@ -547,6 +549,7 @@ disk_set_information(HANDLE handle, uint32 info_class, STREAM in, STREAM out)
|
|||||||
struct stat filestat;
|
struct stat filestat;
|
||||||
time_t write_time, change_time, access_time, mod_time;
|
time_t write_time, change_time, access_time, mod_time;
|
||||||
struct utimbuf tvs;
|
struct utimbuf tvs;
|
||||||
|
struct STATFS_T stat_fs;
|
||||||
|
|
||||||
pfinfo = &(g_fileinfo[handle]);
|
pfinfo = &(g_fileinfo[handle]);
|
||||||
|
|
||||||
@ -629,6 +632,12 @@ disk_set_information(HANDLE handle, uint32 info_class, STREAM in, STREAM out)
|
|||||||
|
|
||||||
if (fchmod(handle, mode))
|
if (fchmod(handle, mode))
|
||||||
return STATUS_ACCESS_DENIED;
|
return STATUS_ACCESS_DENIED;
|
||||||
|
|
||||||
|
/* prevents start of writing if not enough space left on device */
|
||||||
|
if (STATFS_FN(g_rdpdr_device[pfinfo->device_id].local_path, &stat_fs) == 0)
|
||||||
|
if (stat_fs.f_bsize * stat_fs.f_bfree < length)
|
||||||
|
return STATUS_DISK_FULL;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 10: /* FileRenameInformation */
|
case 10: /* FileRenameInformation */
|
||||||
|
31
rdpdr.c
31
rdpdr.c
@ -89,6 +89,8 @@ add_async_iorequest(uint32 device, uint32 file, uint32 id, uint32 major, uint32
|
|||||||
if (g_iorequest == NULL)
|
if (g_iorequest == NULL)
|
||||||
{
|
{
|
||||||
g_iorequest = (struct async_iorequest *) xmalloc(sizeof(struct async_iorequest));
|
g_iorequest = (struct async_iorequest *) xmalloc(sizeof(struct async_iorequest));
|
||||||
|
if (!g_iorequest)
|
||||||
|
return False;
|
||||||
g_iorequest->fd = 0;
|
g_iorequest->fd = 0;
|
||||||
g_iorequest->next = NULL;
|
g_iorequest->next = NULL;
|
||||||
}
|
}
|
||||||
@ -102,6 +104,8 @@ add_async_iorequest(uint32 device, uint32 file, uint32 id, uint32 major, uint32
|
|||||||
{
|
{
|
||||||
iorq->next =
|
iorq->next =
|
||||||
(struct async_iorequest *) xmalloc(sizeof(struct async_iorequest));
|
(struct async_iorequest *) xmalloc(sizeof(struct async_iorequest));
|
||||||
|
if (!iorq->next)
|
||||||
|
return False;
|
||||||
iorq->next->fd = 0;
|
iorq->next->fd = 0;
|
||||||
iorq->next->next = NULL;
|
iorq->next->next = NULL;
|
||||||
}
|
}
|
||||||
@ -388,6 +392,11 @@ rdpdr_process_irp(STREAM s)
|
|||||||
if (rw_blocking) // Complete read immediately
|
if (rw_blocking) // Complete read immediately
|
||||||
{
|
{
|
||||||
buffer = (uint8 *) xrealloc((void *) buffer, length);
|
buffer = (uint8 *) xrealloc((void *) buffer, length);
|
||||||
|
if (!buffer)
|
||||||
|
{
|
||||||
|
status = STATUS_CANCELLED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
status = fns->read(file, buffer, length, offset, &result);
|
status = fns->read(file, buffer, length, offset, &result);
|
||||||
buffer_len = result;
|
buffer_len = result;
|
||||||
break;
|
break;
|
||||||
@ -395,6 +404,11 @@ rdpdr_process_irp(STREAM s)
|
|||||||
|
|
||||||
// Add request to table
|
// Add request to table
|
||||||
pst_buf = (uint8 *) xmalloc(length);
|
pst_buf = (uint8 *) xmalloc(length);
|
||||||
|
if (!pst_buf)
|
||||||
|
{
|
||||||
|
status = STATUS_CANCELLED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
serial_get_timeout(file, length, &total_timeout, &interval_timeout);
|
serial_get_timeout(file, length, &total_timeout, &interval_timeout);
|
||||||
if (add_async_iorequest
|
if (add_async_iorequest
|
||||||
(device, file, id, major, length, fns, total_timeout, interval_timeout,
|
(device, file, id, major, length, fns, total_timeout, interval_timeout,
|
||||||
@ -430,6 +444,12 @@ rdpdr_process_irp(STREAM s)
|
|||||||
|
|
||||||
// Add to table
|
// Add to table
|
||||||
pst_buf = (uint8 *) xmalloc(length);
|
pst_buf = (uint8 *) xmalloc(length);
|
||||||
|
if (!pst_buf)
|
||||||
|
{
|
||||||
|
status = STATUS_CANCELLED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
in_uint8a(s, pst_buf, length);
|
in_uint8a(s, pst_buf, length);
|
||||||
|
|
||||||
if (add_async_iorequest
|
if (add_async_iorequest
|
||||||
@ -553,6 +573,12 @@ rdpdr_process_irp(STREAM s)
|
|||||||
in_uint8s(s, 0x14);
|
in_uint8s(s, 0x14);
|
||||||
|
|
||||||
buffer = (uint8 *) xrealloc((void *) buffer, bytes_out + 0x14);
|
buffer = (uint8 *) xrealloc((void *) buffer, bytes_out + 0x14);
|
||||||
|
if (!buffer)
|
||||||
|
{
|
||||||
|
status = STATUS_CANCELLED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
out.data = out.p = buffer;
|
out.data = out.p = buffer;
|
||||||
out.size = sizeof(buffer);
|
out.size = sizeof(buffer);
|
||||||
status = fns->device_control(file, request, s, &out);
|
status = fns->device_control(file, request, s, &out);
|
||||||
@ -568,8 +594,9 @@ rdpdr_process_irp(STREAM s)
|
|||||||
{
|
{
|
||||||
rdpdr_send_completion(device, id, status, result, buffer, buffer_len);
|
rdpdr_send_completion(device, id, status, result, buffer, buffer_len);
|
||||||
}
|
}
|
||||||
xfree(buffer);
|
if (buffer)
|
||||||
|
xfree(buffer);
|
||||||
|
buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user