Give source code info in rdp_protocol_error()

Makes it easier to debug things by seeing exactly where the protocol
handling crashed.
This commit is contained in:
Pierre Ossman 2019-04-09 14:02:42 +02:00
parent 092fc20921
commit d8b0f3782a
8 changed files with 19 additions and 16 deletions

View File

@ -130,7 +130,7 @@ cliprdr_process(STREAM s)
if (!s_check_rem(s, length)) if (!s_check_rem(s, length))
{ {
rdp_protocol_error("cliprdr_process(), consume of packet from stream would overrun", &packet); rdp_protocol_error("consume of packet from stream would overrun", &packet);
} }
if (status == CLIPRDR_ERROR) if (status == CLIPRDR_ERROR)

4
cssp.c
View File

@ -637,7 +637,7 @@ cssp_read_tsrequest(STREAM token, STREAM pubkey)
if (!s_check_rem(s, length)) if (!s_check_rem(s, length))
{ {
rdp_protocol_error("cssp_read_tsrequest(), consume of version from stream would overrun", rdp_protocol_error("consume of version from stream would overrun",
&packet); &packet);
} }
in_uint8s(s, length); in_uint8s(s, length);
@ -663,7 +663,7 @@ cssp_read_tsrequest(STREAM token, STREAM pubkey)
if (!s_check_rem(s, length)) if (!s_check_rem(s, length))
{ {
rdp_protocol_error("cssp_read_tsrequest(), consume of token from stream would overrun", rdp_protocol_error("consume of token from stream would overrun",
&packet); &packet);
} }

4
mcs.c
View File

@ -52,7 +52,7 @@ mcs_parse_domain_params(STREAM s)
if (!s_check_rem(s, length)) if (!s_check_rem(s, length))
{ {
rdp_protocol_error("mcs_parse_domain_params(), consume domain params from stream would overrun", &packet); rdp_protocol_error("consume domain params from stream would overrun", &packet);
} }
in_uint8s(s, length); in_uint8s(s, length);
@ -125,7 +125,7 @@ mcs_recv_connect_response(STREAM mcs_data)
if (!s_check_rem(s, length)) if (!s_check_rem(s, length))
{ {
rdp_protocol_error("mcs_recv_connect_response(), consume connect id from stream would overrun", &packet); rdp_protocol_error("consume connect id from stream would overrun", &packet);
} }
mcs_parse_domain_params(s); mcs_parse_domain_params(s);

View File

@ -1272,7 +1272,7 @@ process_secondary_order(STREAM s)
if (!s_check_rem(s, length)) if (!s_check_rem(s, length))
{ {
rdp_protocol_error("process_secondary_order(), next order pointer would overrun stream", &packet); rdp_protocol_error("next order pointer would overrun stream", &packet);
} }
next_order = s->p + length; next_order = s->p + length;

View File

@ -165,7 +165,9 @@ RD_BOOL rdp_connect(char *server, uint32 flags, char *domain, char *password, ch
char *directory, RD_BOOL reconnect); char *directory, RD_BOOL reconnect);
void rdp_reset_state(void); void rdp_reset_state(void);
void rdp_disconnect(void); void rdp_disconnect(void);
void rdp_protocol_error(const char *message, STREAM s); #define rdp_protocol_error(m, s) _rdp_protocol_error(__FILE__, __LINE__, __func__, m, s)
void _rdp_protocol_error(const char *file, int line, const char *func,
const char *message, STREAM s);
/* rdpdr.c */ /* rdpdr.c */
int get_device_index(RD_NTHANDLE handle); int get_device_index(RD_NTHANDLE handle);
void convert_to_unix_filename(char *filename); void convert_to_unix_filename(char *filename);

11
rdp.c
View File

@ -298,7 +298,7 @@ rdp_in_unistr(STREAM s, int in_len, char **string, uint32 * str_size)
if (!s_check_rem(s, in_len)) if (!s_check_rem(s, in_len))
{ {
rdp_protocol_error("rdp_in_unistr(), consume of unicode data from stream would overrun", &packet); rdp_protocol_error("consume of unicode data from stream would overrun", &packet);
} }
// if not already open // if not already open
@ -1269,7 +1269,7 @@ process_demand_active(STREAM s)
if (!s_check_rem(s, len_src_descriptor)) if (!s_check_rem(s, len_src_descriptor))
{ {
rdp_protocol_error("rdp_demand_active(), consume of source descriptor from stream would overrun", &packet); rdp_protocol_error("consume of source descriptor from stream would overrun", &packet);
} }
in_uint8s(s, len_src_descriptor); in_uint8s(s, len_src_descriptor);
@ -1522,7 +1522,7 @@ process_bitmap_data(STREAM s)
/* read compressed bitmap data */ /* read compressed bitmap data */
if (!s_check_rem(s, size)) if (!s_check_rem(s, size))
{ {
rdp_protocol_error("process_bitmap_data(), consume of bitmap data from stream would overrun", &packet); rdp_protocol_error("consume of bitmap data from stream would overrun", &packet);
} }
in_uint8p(s, data, size); in_uint8p(s, data, size);
bmpdata = (uint8 *) xmalloc(width * height * Bpp); bmpdata = (uint8 *) xmalloc(width * height * Bpp);
@ -2112,9 +2112,10 @@ rdp_disconnect(void)
*/ */
void void
rdp_protocol_error(const char *message, STREAM s) _rdp_protocol_error(const char *file, int line, const char *func,
const char *message, STREAM s)
{ {
logger(Protocol, Error, "%s(), %s", __func__, message); logger(Protocol, Error, "%s:%d: %s(), %s", file, line, func, message);
if (s) if (s)
hexdump(s->p, s_length(s)); hexdump(s->p, s_length(s));
exit(0); exit(0);

View File

@ -273,7 +273,7 @@ rdpsnd_process_training(STREAM in)
if (!s_check_rem(in, 4)) if (!s_check_rem(in, 4))
{ {
rdp_protocol_error("rdpsnd_process_training(), consume of training data from stream would overrun", &packet); rdp_protocol_error("consume of training data from stream would overrun", &packet);
} }
in_uint16_le(in, tick); in_uint16_le(in, tick);

View File

@ -873,7 +873,7 @@ sec_recv(RD_BOOL * is_fastpath)
if (fastpath_flags & FASTPATH_OUTPUT_ENCRYPTED) if (fastpath_flags & FASTPATH_OUTPUT_ENCRYPTED)
{ {
if (!s_check_rem(s, 8)) { if (!s_check_rem(s, 8)) {
rdp_protocol_error("sec_recv(), consume fastpath signature from stream would overrun", &packet); rdp_protocol_error("consume fastpath signature from stream would overrun", &packet);
} }
in_uint8s(s, 8); /* signature */ in_uint8s(s, 8); /* signature */
@ -893,7 +893,7 @@ sec_recv(RD_BOOL * is_fastpath)
if (sec_flags & SEC_ENCRYPT) if (sec_flags & SEC_ENCRYPT)
{ {
if (!s_check_rem(s, 8)) { if (!s_check_rem(s, 8)) {
rdp_protocol_error("sec_recv(), consume encrypt signature from stream would overrun", &packet); rdp_protocol_error("consume encrypt signature from stream would overrun", &packet);
} }
in_uint8s(s, 8); /* signature */ in_uint8s(s, 8); /* signature */
@ -911,7 +911,7 @@ sec_recv(RD_BOOL * is_fastpath)
uint8 swapbyte; uint8 swapbyte;
if (!s_check_rem(s, 8)) { if (!s_check_rem(s, 8)) {
rdp_protocol_error("sec_recv(), consume redirect signature from stream would overrun", &packet); rdp_protocol_error("consume redirect signature from stream would overrun", &packet);
} }
in_uint8s(s, 8); /* signature */ in_uint8s(s, 8); /* signature */