From 5d608b3500c92cc32111254522667b05380e1605 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 3 Nov 2015 15:41:28 -0800 Subject: [PATCH] GUAC-363: Warn of invalid preconnection IDs. --- src/protocols/rdp/client.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/protocols/rdp/client.c b/src/protocols/rdp/client.c index 8d34a6d2..6bf51cb3 100644 --- a/src/protocols/rdp/client.c +++ b/src/protocols/rdp/client.c @@ -780,9 +780,21 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /* Preconnection ID */ settings->preconnection_id = -1; if (argv[IDX_PRECONNECTION_ID][0] != '\0') { - settings->preconnection_id = atoi(argv[IDX_PRECONNECTION_ID]); - guac_client_log(client, GUAC_LOG_DEBUG, - "Preconnection ID: %i", settings->preconnection_id); + + /* Parse preconnection ID, warn if invalid */ + int preconnection_id = atoi(argv[IDX_PRECONNECTION_ID]); + if (preconnection_id < 0) + guac_client_log(client, GUAC_LOG_WARNING, + "Ignoring invalid preconnection ID: %i", + preconnection_id); + + /* Otherwise, assign specified ID */ + else { + settings->preconnection_id = preconnection_id; + guac_client_log(client, GUAC_LOG_DEBUG, + "Preconnection ID: %i", settings->preconnection_id); + } + } /* Preconnection BLOB */