diff options
author | Jay Sorg <jay.sorg@gmail.com> | 2016-12-04 15:39:10 -0800 |
---|---|---|
committer | Jay Sorg <jay.sorg@gmail.com> | 2016-12-04 15:39:10 -0800 |
commit | 9a517b34f0f4eb546c46ad4185260f4b66773a8c (patch) | |
tree | acba9d4d05b0b495cfe628fb585001837407e371 | |
parent | 57905d71ada103ae397e441e2c14b6f64c365a69 (diff) | |
download | xrdp-proprietary-9a517b34f0f4eb546c46ad4185260f4b66773a8c.tar.gz xrdp-proprietary-9a517b34f0f4eb546c46ad4185260f4b66773a8c.zip |
vnc: code cleanup
-rw-r--r-- | common/os_calls.c | 28 | ||||
-rw-r--r-- | common/os_calls.h | 2 | ||||
-rw-r--r-- | sesman/session.c | 17 | ||||
-rw-r--r-- | vnc/vnc.c | 10 | ||||
-rw-r--r-- | xrdp/xrdp_mm.c | 2 |
5 files changed, 35 insertions, 24 deletions
diff --git a/common/os_calls.c b/common/os_calls.c index d8e711b8..9ebaa880 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -2531,6 +2531,34 @@ g_htoi(char *str) } /*****************************************************************************/ +/* returns number of bytes copied into out_str */ +int APP_CC +g_bytes_to_hexstr(const void *bytes, int num_bytes, char *out_str, + int bytes_out_str) +{ + int rv; + int index; + char *lout_str; + const tui8 *lbytes; + + rv = 0; + lbytes = (const tui8 *) bytes; + lout_str = out_str; + for (index = 0; index < num_bytes; index++) + { + if (bytes_out_str < 3) + { + break; + } + g_snprintf(lout_str, bytes_out_str, "%2.2x", lbytes[index]); + lout_str += 2; + bytes_out_str -= 2; + rv += 2; + } + return rv; +} + +/*****************************************************************************/ int APP_CC g_pos(const char *str, const char *to_find) { diff --git a/common/os_calls.h b/common/os_calls.h index 00e91a1d..6a206726 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -134,6 +134,8 @@ int APP_CC g_strcasecmp(const char* c1, const char* c2); int APP_CC g_strncasecmp(const char* c1, const char* c2, int len); int APP_CC g_atoi(const char* str); int APP_CC g_htoi(char* str); +int APP_CC g_bytes_to_hexstr(const void *bytes, int num_bytes, char *out_str, + int bytes_out_str); int APP_CC g_pos(const char* str, const char* to_find); int APP_CC g_mbstowcs(twchar* dest, const char* src, int n); int APP_CC g_wcstombs(char* dest, const twchar* src, int n); diff --git a/sesman/session.c b/sesman/session.c index 778e8b4c..de3b9f70 100644 --- a/sesman/session.c +++ b/sesman/session.c @@ -697,20 +697,9 @@ session_start_fork(tbus data, tui8 type, struct SCP_SESSION *s) } else if (type == SESMAN_SESSION_TYPE_XVNC) { - if (s->guid != 0) - { - char guid_str[64]; - char *pguid_str; - int index; - pguid_str = guid_str; - for (index = 0; index < 16; index++) - { - g_snprintf(pguid_str, 4, "%2.2x", s->guid[index]); - pguid_str += 2; - } - guid_str[32] = 0; - env_check_password_file(passwd_file, guid_str); - } + char guid_str[64]; + g_bytes_to_hexstr(s->guid, 16, guid_str, 64); + env_check_password_file(passwd_file, guid_str); xserver_params = list_create(); xserver_params->auto_free = 1; @@ -1097,15 +1097,7 @@ lib_mod_connect(struct vnc *v) if (v->got_guid) { char guid_str[64]; - char *pguid_str; - int index; - pguid_str = guid_str; - for (index = 0; index < 16; index++) - { - g_snprintf(pguid_str, 4, "%2.2x", v->guid[index]); - pguid_str += 2; - } - guid_str[32] = 0; + g_bytes_to_hexstr(v->guid, 16, guid_str, 64); rfbHashEncryptBytes(s->data, guid_str); } else diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 8d1c251c..715a18fc 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -565,7 +565,7 @@ xrdp_mm_setup_mod2(struct xrdp_mm *self, tui8 *guid) self->mod->mod_set_param(self->mod, "keylayout", text); if (guid != 0) { - self->mod->mod_set_param(self->mod, "guid", (char*)guid); + self->mod->mod_set_param(self->mod, "guid", (char *) guid); } for (i = 0; i < self->login_names->count; i++) |