Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#3 invalid device with ttylog 0.25 Edit

BaudRate
open
0.2.0
1
2014-07-29
2014-02-14
Daniel Flinkmann
No

dan@cb2b:~# ttylog -v
ttylog version 0.25.
dan@cb2b:~# ttylog -d /dev/ttyUSB0
ttylog: invalid device /d
dan@cb2b:~#

The problem is caused by the additional \0 when copying the argv to the modem_device string. it will always be cut off after 2 chars.

The solution is pretty easy:
dan@cb2b:~# diff -Nur ttylog-code/ttylog.c_orig ttylog-code/ttylog.c
--- ttylog-code/ttylog.c_orig 2014-02-14 23:35:13.311886020 +0000
+++ ttylog-code/ttylog.c 2014-02-14 23:35:48.661886037 +0000
@@ -97,7 +97,7 @@
{
memset (modem_device, '\0', sizeof(modem_device));
strncpy (modem_device, argv[i + 1], sizeof(modem_device)-1);
- modem_device[i + 1] = '\0';
+ modem_device[(sizeof(modem_device)-1)] = '\0';
}
else
{

(tested on ubuntu linux)

1 Attachments

Discussion


Anonymous


Cancel   Add attachments