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

    https://github.com/apache/guacamole-server/pull/183#discussion_r216996138
  
    --- Diff: src/libguac/parser.c ---
    @@ -222,7 +222,11 @@ int guac_parser_read(guac_parser* parser, guac_socket* 
socket, int usec_timeout)
                 retval = guac_socket_select(socket, usec_timeout);
                 if (retval <= 0)
                     return -1;
    -           
    +            
    +            /* Reset pointers if instruction buf len is less than max 
instruction len */
    +            if (buffer_end - unparsed_end < GUAC_INSTRUCTION_MAX_LENGTH)
    +                unparsed_end = unparsed_start = parser->__instructionbuf;
    --- End diff --
    
    Here, I've added debug logging for each block written by `write()` within 
`__write_all()` as well as each block read via `guac_socket_read()` within the 
parser:
    
    https://github.com/mike-jumper/guacamole-server/tree/debug-io
    
    The logging added above should be stable in the sense that:
    
    1. Reads and writes are written to separate files and thus the log 
shouldn't become corrupt if they happen to overlap.
    2. The log routine does not expect a null terminator, relying instead on a 
supplied length, so there shouldn't be garbage / stale bytes in the logs that 
weren't actually read/written at the time logged.
    
    Reads are logged to `read-log.txt` within the current directory of guacd 
and writes are logged to `write-log.txt` within the current directory of guacd. 
The logged data is in hex dump format and will generally look like this:
    
    ```
    --- 25 bytes:
    00000000:  34 2E 73 69 7A 65 2C 34 2E 31 31 35 34 2C 33 2E  4.size,4.1154,3.
    00000010:  36 35 34 2C 32 2E 39 36 3B                       654,2.96;
    --- 209 bytes:
    00000000:  35 2E 61 75 64 69 6F 2C 38 2E 61 75 64 69 6F 2F  5.audio,8.audio/
    00000010:  4C 38 2C 39 2E 61 75 64 69 6F 2F 4C 31 36 3B 35  L8,9.audio/L16;5
    00000020:  2E 76 69 64 65 6F 3B 35 2E 69 6D 61 67 65 2C 31  .video;5.image,1
    00000030:  30 2E 69 6D 61 67 65 2F 6A 70 65 67 2C 39 2E 69  0.image/jpeg,9.i
    00000040:  6D 61 67 65 2F 70 6E 67 2C 31 30 2E 69 6D 61 67  mage/png,10.imag
    00000050:  65 2F 77 65 62 70 3B 37 2E 63 6F 6E 6E 65 63 74  e/webp;7.connect
    00000060:  2C 39 2E 6C 6F 63 61 6C 68 6F 73 74 2C 34 2E 35  ,9.localhost,4.5
    00000070:  39 30 31 2C 30 2E 2C 30 2E 2C 30 2E 2C 30 2E 2C  901,0.,0.,0.,0.,
    00000080:  30 2E 2C 30 2E 2C 30 2E 2C 30 2E 2C 30 2E 2C 30  0.,0.,0.,0.,0.,0
    00000090:  2E 2C 30 2E 2C 30 2E 2C 30 2E 2C 30 2E 2C 30 2E  .,0.,0.,0.,0.,0.
    000000A0:  2C 30 2E 2C 30 2E 2C 30 2E 2C 30 2E 2C 30 2E 2C  ,0.,0.,0.,0.,0.,
    000000B0:  30 2E 2C 30 2E 2C 30 2E 2C 30 2E 2C 30 2E 2C 30  0.,0.,0.,0.,0.,0
    000000C0:  2E 2C 30 2E 2C 30 2E 2C 30 2E 2C 30 2E 2C 30 2E  .,0.,0.,0.,0.,0.
    000000D0:  3B                                               ;
    --- 30 bytes:
    00000000:  39 2E 63 6C 69 70 62 6F 61 72 64 2C 31 2E 30 2C  9.clipboard,1.0,
    00000010:  31 30 2E 74 65 78 74 2F 70 6C 61 69 6E 3B        10.text/plain;
    --- 76 bytes:
    00000000:  33 2E 65 6E 64 2C 31 2E 30 3B 35 2E 61 75 64 69  3.end,1.0;5.audi
    00000010:  6F 2C 31 2E 30 2C 33 31 2E 61 75 64 69 6F 2F 4C  o,1.0,31.audio/L
    00000020:  31 36 3B 72 61 74 65 3D 34 34 31 30 30 2C 63 68  16;rate=44100,ch
    00000030:  61 6E 6E 65 6C 73 3D 32 3B 34 2E 73 79 6E 63 2C  annels=2;4.sync,
    00000040:  39 2E 38 33 30 34 34 37 36 30 32 3B              9.830447602;
    ...
    ```
    
    This should hopefully give us cleaner, more thorough logs.
    
    Please try to reproduce the parse error with the above branch and provide 
the resulting `write-log.txt` and `read-log.txt` for the connection that 
failed. Be sure to remove the `write-log.txt` and `read-log.txt` files between 
connection attempts, as the debug code just repeatedly appends to those files. 
If the files exist at the beginning of a connection, the old log data will 
still be there.


---

Reply via email to