Package: ser2net
Version: 2.9.1-1.1
Severity: important
Tags: patch
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Dear Maintainer,
ser2net stopped listening after upgrading from wheezy to jessie.
Running it with debugging showed that it failed to parse the
old configuration file:
ser2net[16570]: Error on line 67, port number was invalid
ser2net[16570]: Error on line 68, port number was invalid
ser2net[16570]: Error on line 69, port number was invalid
ser2net[16570]: Error on line 70, port number was invalid
ser2net[16570]: Error on line 71, port number was invalid
Looking more into this is proved to be caused by the "host,port"
syntax used for these entries. Digging into the code I found
that strtok_r() is used to parse these strings multiple times.
Which will not work - strtok_r() modifies its argument...
I guess this bug might have been added while attempting to
support IPv6?
I'm attaching a sort of quick fix, which works for me.
Bjørn
- -- System Information:
Debian Release: 8.0
APT prefers testing
APT policy: (990, 'testing'), (500, 'testing-updates')
Architecture: amd64 (x86_64)
Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)
Versions of packages ser2net depends on:
ii initscripts 2.88dsf-59
ii libc6 2.19-18
ser2net recommends no packages.
Versions of packages ser2net suggests:
ii telnet 0.17-36
- -- Configuration Files:
/etc/default/ser2net changed:
CONFFILE="/etc/ser2net.conf"
CONTROLPORT="127.0.0.1,62000"
/etc/ser2net.conf changed:
10.255.1.6,23:telnet:0:/dev/edgeport0:9600 LOCAL
10.255.1.7,23:telnet:0:/dev/edgeport1:9600 LOCAL
10.255.1.8,23:telnet:0:/dev/edgeport2:38400 LOCAL -RTSCTS
10.255.1.9,23:telnet:0:/dev/edgeport3:9600 LOCAL
10.255.1.10,23:telnet:0:/dev/wrt1900ac:115200 LOCAL
- -- no debconf information
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iEYEARECAAYFAlU3kn4ACgkQ10rqkowbIskg/wCffzKtUtthzDFfJv7Q4R/64wDY
GScAn0tN6bftvBT6Ih53fRAzzwaQNalI
=/+7J
-----END PGP SIGNATURE-----
diff -urN ser2net-2.9.1/controller.c ser2net-2.9.1.new/controller.c
--- ser2net-2.9.1/controller.c 2013-01-29 23:44:17.000000000 +0100
+++ ser2net-2.9.1.new/controller.c 2015-04-22 13:46:07.485931943 +0200
@@ -719,13 +719,13 @@
socklen_t sock_len;
int optval = 1;
- if (scan_tcp_port(controller_port, AF_UNSPEC, &sock, &sock_len) == -1)
+ if (scan_tcp_port(controller_port, AF_UNSPEC, &sock, &sock_len) < 0)
return CONTROLLER_INVALID_TCP_SPEC;
acceptfd = socket(sock.ss_family, SOCK_STREAM, 0);
if ((acceptfd == -1) && (errno == EAFNOSUPPORT)) {
/* Retry IPV4-only */
- if (scan_tcp_port(controller_port, AF_INET, &sock, &sock_len) == -1)
+ if (scan_tcp_port(controller_port, AF_INET, &sock, &sock_len) < 0)
return CONTROLLER_INVALID_TCP_SPEC;
acceptfd = socket(sock.ss_family, SOCK_STREAM, 0);
}
diff -urN ser2net-2.9.1/dataxfer.c ser2net-2.9.1.new/dataxfer.c
--- ser2net-2.9.1/dataxfer.c 2013-07-27 01:47:14.000000000 +0200
+++ ser2net-2.9.1.new/dataxfer.c 2015-04-22 13:55:08.639469438 +0200
@@ -1753,7 +1753,7 @@
if (scan_tcp_port(port->portname, AF_UNSPEC,
&port->tcpport, &port->tcpport_len)
- == -1)
+ < 0)
{
return "port number was invalid";
}
@@ -1762,7 +1762,7 @@
/* Retry IPV4-only */
if (scan_tcp_port(port->portname, AF_INET,
&port->tcpport, &port->tcpport_len)
- == -1)
+ < 0)
{
return "port number was invalid";
}
@@ -2096,7 +2096,7 @@
if (scan_tcp_port(new_port->portname, AF_UNSPEC,
&new_port->tcpport, &new_port->tcpport_len)
- == -1)
+ < 0)
{
rv = "port number was invalid";
goto errout;
diff -urN ser2net-2.9.1/debian/changelog ser2net-2.9.1.new/debian/changelog
--- ser2net-2.9.1/debian/changelog 2013-08-07 19:53:40.000000000 +0200
+++ ser2net-2.9.1.new/debian/changelog 2015-04-22 13:52:32.088720255 +0200
@@ -1,3 +1,9 @@
+ser2net (2.9.1-1.1) UNRELEASED; urgency=medium
+
+ * fixed host,port parsing
+
+ -- Bjørn Mork <[email protected]> Wed, 22 Apr 2015 13:51:10 +0200
+
ser2net (2.9.1-1) unstable; urgency=low
* New Upstream Version
diff -urN ser2net-2.9.1/utils.c ser2net-2.9.1.new/utils.c
--- ser2net-2.9.1/utils.c 2013-01-29 23:41:41.000000000 +0100
+++ ser2net-2.9.1.new/utils.c 2015-04-22 13:46:59.078845515 +0200
@@ -25,6 +25,7 @@
#include <arpa/inet.h>
#include <errno.h>
#include <unistd.h>
+#include <stdlib.h>
#include "utils.h"
@@ -70,11 +71,13 @@
char *strtok_data;
char *ip;
char *port;
+ char *tmp;
+ int ret;
struct addrinfo hints, *ai;
memset(addr, 0, sizeof(*addr));
-
- ip = strtok_r(str, ",", &strtok_data);
+ tmp = strdup(str);
+ ip = strtok_r(tmp, ",", &strtok_data);
port = strtok_r(NULL, "", &strtok_data);
if (port == NULL) {
port = ip;
@@ -84,13 +87,16 @@
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_PASSIVE;
hints.ai_family = domain;
- if (getaddrinfo(ip, port, &hints, &ai))
- return -1;
+ ret = getaddrinfo(ip, port, &hints, &ai);
+ free(tmp);
+ if (ret < 0)
+ goto err;
memcpy(addr, ai->ai_addr, ai->ai_addrlen);
*addr_len = ai->ai_addrlen;
freeaddrinfo(ai);
- return 0;
+err:
+ return ret;
}
void