mike-jumper commented on a change in pull request #219: GUACAMOLE-422: Add
timezone to client handshake
URL: https://github.com/apache/guacamole-server/pull/219#discussion_r277067044
##########
File path: src/libguac/user-handlers.c
##########
@@ -581,3 +593,131 @@ int __guac_handle_disconnect(guac_user* user, int argc,
char** argv) {
return 0;
}
+/* Guacamole handshake handler functions. */
+
+int __guac_handshake_size_handler(guac_user* user, int argc, char** argv) {
+
+ /* Validate size of instruction. */
+ if (argc < 2) {
+ guac_user_log(user, GUAC_LOG_ERROR, "Received \"size\" "
+ "instruction lacked required arguments.");
+ return 1;
+ }
+
+ /* Parse optimal screen dimensions from size instruction */
+ user->info.optimal_width = atoi(argv[0]);
+ user->info.optimal_height = atoi(argv[1]);
+
+ /* If DPI given, set the user resolution */
+ if (argc >= 3)
+ user->info.optimal_resolution = atoi(argv[2]);
+
+ /* Otherwise, use a safe default for rough backwards compatibility */
+ else
+ user->info.optimal_resolution = 96;
+
+ return 0;
+
+}
+
+int __guac_handshake_audio_handler(guac_user* user, int argc, char** argv) {
+
+ guac_free_mimetypes((char **) user->info.audio_mimetypes);
+
+ /* Store audio mimetypes */
+ user->info.audio_mimetypes = (const char**) guac_copy_mimetypes(argv,
argc);
+
+ return 0;
+
+}
+
+int __guac_handshake_video_handler(guac_user* user, int argc, char** argv) {
+
+ guac_free_mimetypes((char **) user->info.video_mimetypes);
+
+ /* Store video mimetypes */
+ user->info.video_mimetypes = (const char**) guac_copy_mimetypes(argv,
argc);
+
+ return 0;
+
+}
+
+int __guac_handshake_image_handler(guac_user* user, int argc, char** argv) {
+
+ guac_free_mimetypes((char **) user->info.image_mimetypes);
+
+ /* Store image mimetypes */
+ user->info.image_mimetypes = (const char**) guac_copy_mimetypes(argv,
argc);
+
+ return 0;
+
+}
+
+int __guac_handshake_timezone_handler(guac_user* user, int argc, char** argv) {
+
+ /* Free any past value */
+ free((char *) user->info.timezone);
+
+ /* Store timezone, if present */
+ if (argc > 0 && strcmp(argv[0], ""))
+ user->info.timezone = (const char*) strdup(argv[0]);
Review comment:
In the case of the following sequence:
1. `8.timezone,6.foobar;`
2. `8.timezone;`
`user->info.timezone` will contain a stale pointer to the old, freed
`"foobar"` memory, rather than `NULL`. I think this should explicitly assign
`NULL` in the blank/omitted case.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services