Github user necouchman commented on a diff in the pull request: https://github.com/apache/guacamole-server/pull/154#discussion_r178701688 --- Diff: src/protocols/rdp/guac_rdpdr/rdpdr_printer.c --- @@ -141,18 +143,25 @@ 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 = guac_utf8_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, + settings_length, printer_name, printer_name_length); + printer_name[printer_name_length - 2] = '\0'; + printer_name[printer_name_length - 1] = '\0'; + Stream_Write_UINT32(output_stream, 24 + GUAC_PRINTER_DRIVER_LENGTH + printer_name_length); Stream_Write_UINT32(output_stream, RDPDR_PRINTER_ANNOUNCE_FLAG_DEFAULTPRINTER | RDPDR_PRINTER_ANNOUNCE_FLAG_NETWORKPRINTER); Stream_Write_UINT32(output_stream, 0); /* reserved - must be 0 */ Stream_Write_UINT32(output_stream, 0); /* PnPName length (PnPName is ultimately ignored) */ Stream_Write_UINT32(output_stream, GUAC_PRINTER_DRIVER_LENGTH); /* DriverName length */ - Stream_Write_UINT32(output_stream, GUAC_PRINTER_NAME_LENGTH); /* PrinterName length */ + Stream_Write_UINT32(output_stream, printer_name_length); /* PrinterName length */ Stream_Write_UINT32(output_stream, 0); /* CachedFields length */ Stream_Write(output_stream, GUAC_PRINTER_DRIVER, GUAC_PRINTER_DRIVER_LENGTH); - Stream_Write(output_stream, GUAC_PRINTER_NAME, GUAC_PRINTER_NAME_LENGTH); + Stream_Write(output_stream, printer_name, printer_name_length); --- End diff -- Well, I've taken a stab at the implementation of this, as seen in the latest commit. It feels far, far away from anywhere near good at this point, but you can take a look and let me know if I'm on the right track and make suggestions. The whole double loop thing just feels wrong, but I'm not sure how else to get the number of bytes before opening the stream and then actually write the stream data.
---