Github user mike-jumper commented on a diff in the pull request:

    https://github.com/apache/guacamole-server/pull/154#discussion_r171998500
  
    --- Diff: src/protocols/rdp/guac_rdpdr/rdpdr_printer.c ---
    @@ -141,18 +142,23 @@ static void 
guac_rdpdr_device_printer_announce_handler(guac_rdpdr_device* device
         Stream_Write(output_stream, "PRN1\0\0\0\0", 8); /* DOS name */
     
         /* Printer data */
    -    Stream_Write_UINT32(output_stream, 24 + GUAC_PRINTER_DRIVER_LENGTH + 
GUAC_PRINTER_NAME_LENGTH);
    +    int settings_length = strlen(device->device_name);
    +    int printer_name_length = (settings_length + 1) * 2;
    +    char* printer_name = malloc(printer_name_length);
    +    guac_rdp_utf8_to_utf16((const unsigned char*)device->device_name, 
    --- End diff --
    
    Beware that `guac_rdp_utf8_to_utf16()`, confusingly, does not automatically 
null-terminate the output string. I'm not sure at the moment whether that is an 
oversight, or whether things will break if that function is modified to 
properly null-terminate things, but this will somehow need to be taken into 
account.
    
    Probably a good idea for us to update the documentation for those utility 
functions while we're at it, as it's problematic for the null-terminator 
behavior to be undocumented and different between the two.


---

Reply via email to