-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Description
If the number of bytes being copied from stdin to kitten clipboard is:
(8192 * n + 1) for all n where n >= 0 and n % 3 != 1 or
(8192 * n + 2) for all n where n >= 0 and n % 3 == 0,
then the clipboard kitten will hang indefinitely.
Reproducing
kitten clipboard <<< "" # \nor
kitten clipboard <<< "a" # a\nor
python -c "print('a' * 16385, end='')" | kitten clipboard...and so on
For all the values of n described above, the final read from data_src in write_one_chunk returns less than 3 bytes. Those bytes are then written to the base64 encoder enc. However, this small write doesn't trigger a write to the underlying base64_streaming_enc. This means data is never submitted to the loop and so OnWriteComplete is never called. Since data_src only gets read again as a result of OnWriteComplete, and because data_src has a Read implementation that doesn't return EOF until an attempt to read past n, the kitten hangs indefinitely.