You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that the tbh handling functions (get_tbh_size and set_tbh_size) are suffering from an arithmetic overflow when all 8 lower bits are used, making the connection close when dealing with messages between 128 and 255 bytes.
Simplistic patch that at least makes the issues go away in my environment.
diff --git a/c_src/serial.c b/c_src/serial.c
index 8751be6..895e0aa 100644
--- a/c_src/serial.c
+++ b/c_src/serial.c
@@ -214,7 +214,7 @@ void set_tty_speed(int fd, speed_t new_ispeed, speed_t new_ospeed)
* Desc: returns the size of a two_byte_header message (from Erlang).
*/
-int get_tbh_size(char buf[])
+int get_tbh_size(unsigned char buf[])
{
return (((int) buf[0]) << 8) + ((int) buf[1]);
}
@@ -441,7 +441,7 @@ main(int argc, char *argv[])
{
fd_set readfds; /* file descriptor bit field for select */
int maxfd; /* max file descriptor for select */
- char buf[MAXLENGTH]; /* buffer for transfer between serial-user */
+ unsigned char buf[MAXLENGTH];/* buffer for transfer between serial-user */
int escapes; /* number of consecutive escapes in cbreak */
/* Set up initial bit field for select */
The text was updated successfully, but these errors were encountered:
It seems that the tbh handling functions (get_tbh_size and set_tbh_size) are suffering from an arithmetic overflow when all 8 lower bits are used, making the connection close when dealing with messages between 128 and 255 bytes.
Simplistic patch that at least makes the issues go away in my environment.
The text was updated successfully, but these errors were encountered: