GUACAMOLE-422: Add debugging and check argument count.
This commit is contained in:
parent
4b43de963e
commit
93a240b8ad
@ -719,7 +719,9 @@ int __guac_user_call_opcode_handler(__guac_instruction_handler_mapping* map,
|
|||||||
current++;
|
current++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If unrecognized, ignore */
|
/* If unrecognized, log and ignore */
|
||||||
|
guac_user_log(user, GUAC_LOG_WARNING, "Handler not found for \"%s\"",
|
||||||
|
opcode);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ static void* guac_user_input_thread(void* data) {
|
|||||||
|
|
||||||
/* Call handler, stop on error */
|
/* Call handler, stop on error */
|
||||||
if (__guac_user_call_opcode_handler(__guac_instruction_handler_map,
|
if (__guac_user_call_opcode_handler(__guac_instruction_handler_map,
|
||||||
user, parser->opcode, parser->argc, parser->argv) < 0) {
|
user, parser->opcode, parser->argc, parser->argv)) {
|
||||||
|
|
||||||
/* Log error */
|
/* Log error */
|
||||||
guac_user_log_guac_error(user, GUAC_LOG_WARNING,
|
guac_user_log_guac_error(user, GUAC_LOG_WARNING,
|
||||||
@ -271,7 +271,7 @@ static int __guac_user_handshake(guac_user* user, guac_parser* parser,
|
|||||||
|
|
||||||
guac_user_log_handshake_failure(user);
|
guac_user_log_handshake_failure(user);
|
||||||
guac_user_log_guac_error(user, GUAC_LOG_DEBUG,
|
guac_user_log_guac_error(user, GUAC_LOG_DEBUG,
|
||||||
"Error handling handling opcode during handshake.");
|
"Error handling instruction during handshake.");
|
||||||
guac_user_log(user, GUAC_LOG_DEBUG, "Failed opcode: %s",
|
guac_user_log(user, GUAC_LOG_DEBUG, "Failed opcode: %s",
|
||||||
parser->opcode);
|
parser->opcode);
|
||||||
|
|
||||||
@ -282,7 +282,9 @@ static int __guac_user_handshake(guac_user* user, guac_parser* parser,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we get here something has gone wrong. */
|
/* If we get here it's because we never got the connect instruction. */
|
||||||
|
guac_user_log(user, GUAC_LOG_ERROR,
|
||||||
|
"Handshake failed, \"connect\" instruction was not received.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,6 +298,10 @@ int guac_user_handle_connection(guac_user* user, int usec_timeout) {
|
|||||||
user->info.video_mimetypes = NULL;
|
user->info.video_mimetypes = NULL;
|
||||||
user->info.timezone = NULL;
|
user->info.timezone = NULL;
|
||||||
|
|
||||||
|
/* Count number of arguments. */
|
||||||
|
int numArgs;
|
||||||
|
for (numArgs = 0; client->args[numArgs] != NULL; numArgs++);
|
||||||
|
|
||||||
/* Send args */
|
/* Send args */
|
||||||
if (guac_protocol_send_args(socket, client->args)
|
if (guac_protocol_send_args(socket, client->args)
|
||||||
|| guac_socket_flush(socket)) {
|
|| guac_socket_flush(socket)) {
|
||||||
@ -312,16 +318,21 @@ int guac_user_handle_connection(guac_user* user, int usec_timeout) {
|
|||||||
|
|
||||||
/* Perform the handshake with the client. */
|
/* Perform the handshake with the client. */
|
||||||
if (__guac_user_handshake(user, parser, usec_timeout)) {
|
if (__guac_user_handshake(user, parser, usec_timeout)) {
|
||||||
guac_user_log_handshake_failure(user);
|
|
||||||
guac_user_log_guac_error(user, GUAC_LOG_DEBUG,
|
|
||||||
"Error while reading opcode instruction.");
|
|
||||||
guac_parser_free(parser);
|
guac_parser_free(parser);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Acknowledge connection availability */
|
/* Acknowledge connection availability */
|
||||||
guac_protocol_send_ready(socket, client->connection_id);
|
guac_protocol_send_ready(socket, client->connection_id);
|
||||||
guac_socket_flush(socket);
|
guac_socket_flush(socket);
|
||||||
|
|
||||||
|
/* Verify argument count. */
|
||||||
|
if (parser->argc != (numArgs + 1)) {
|
||||||
|
guac_client_log(client, GUAC_LOG_ERROR, "Client did not return the "
|
||||||
|
"expected number of arguments.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Attempt to join user to connection. */
|
/* Attempt to join user to connection. */
|
||||||
if (guac_client_add_user(client, user, (parser->argc - 1), parser->argv + 1))
|
if (guac_client_add_user(client, user, (parser->argc - 1), parser->argv + 1))
|
||||||
guac_client_log(client, GUAC_LOG_ERROR, "User \"%s\" could NOT "
|
guac_client_log(client, GUAC_LOG_ERROR, "User \"%s\" could NOT "
|
||||||
@ -333,6 +344,12 @@ int guac_user_handle_connection(guac_user* user, int usec_timeout) {
|
|||||||
guac_client_log(client, GUAC_LOG_INFO, "User \"%s\" joined connection "
|
guac_client_log(client, GUAC_LOG_INFO, "User \"%s\" joined connection "
|
||||||
"\"%s\" (%i users now present)", user->user_id,
|
"\"%s\" (%i users now present)", user->user_id,
|
||||||
client->connection_id, client->connected_users);
|
client->connection_id, client->connected_users);
|
||||||
|
if (strcmp(parser->argv[0],"") != 0)
|
||||||
|
guac_client_log(client, GUAC_LOG_DEBUG, "Client is using protocol "
|
||||||
|
"version \"%s\"", parser->argv[0]);
|
||||||
|
else
|
||||||
|
guac_client_log(client, GUAC_LOG_DEBUG, "Client has not defined "
|
||||||
|
"its protocol version.");
|
||||||
|
|
||||||
/* Handle user I/O, wait for connection to terminate */
|
/* Handle user I/O, wait for connection to terminate */
|
||||||
guac_user_start(parser, user, usec_timeout);
|
guac_user_start(parser, user, usec_timeout);
|
||||||
|
Loading…
Reference in New Issue
Block a user