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

    https://github.com/apache/guacamole-server/pull/154#discussion_r199620515
  
    --- Diff: src/protocols/rdp/guac_rdpdr/rdpdr_printer.c ---
    @@ -200,10 +182,43 @@ void guac_rdpdr_register_printer(guac_rdpdrPlugin* 
rdpdr) {
         /* Init device */
         device->rdpdr       = rdpdr;
         device->device_id   = id;
    -    device->device_name = "Guacamole Printer";
    +    device->device_name = printer_name;
    +    device->device_name_len = guac_utf8_strlen(device->device_name);
    +    device->device_type = RDPDR_DTYP_PRINT;
    +    device->dos_name = "PRN1\0\0\0\0";
    +    
    +    /* Set up device announce stream */
    +    int prt_name_len = (device->device_name_len + 1) * 2;
    +    device->device_announce_len = 44 + prt_name_len
    +            + GUAC_PRINTER_DRIVER_LENGTH;
    +    char prt_name[prt_name_len];
    --- End diff --
    
    While C99 does allow dynamic allocation of arrays in the manner, beware 
that unbounded use of the stack is dangerous. I would normally recommend 
`malloc()` instead, but perhaps writing directly to the `wStream` buffer would 
be a better option in this case? There would then be no need to copy things 
over, leveraging `Stream_Pointer()` and `Stream_Seek()` to accomplish the same 
through the call to `guac_rdp_utf8_to_utf16()`.


---

Reply via email to