facebookarchive / nailgun

Nailgun is a client, protocol, and server for running Java programs from the command line without incurring the JVM startup overhead.
https://github.com/facebook/nailgun
Other
731 stars 138 forks source link

count bytes (not characters) when sending message #158

Closed mzarnowski closed 2 years ago

mzarnowski commented 5 years ago

For each command, the entire user environment is being send to the server. Any variable in the environment can contain unicodes (e.g. PS1 - prompt configuration)

Sending messages works as follows: given buffer buf (a string):

  1. calculate the amount of bytes sent - by using len(buf)
  2. send the header containing the length of the string message
  3. convert string to bytes using bbuf = to_bytes(buf)
  4. send bytes from bbuf

Bug lies in calculating the byte count: it should be calculated using bytes buffer, not string one.