Blob Blame History Raw
From 1d307be4a95a32fe905793066e866bf64b49ee56 Mon Sep 17 00:00:00 2001
From: Alec Leamas <leamas.alec@gmail.com>
Date: Thu, 22 Dec 2016 16:04:15 +0100
Subject: [PATCH] lircd: Fix --listen option parsing [#249].

---
 daemons/lircd.cpp      | 8 ++++----
 doc/man-source/lircd.8 | 3 ++-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/daemons/lircd.cpp b/daemons/lircd.cpp
index 9fe60c5..e491178 100644
--- a/daemons/lircd.cpp
+++ b/daemons/lircd.cpp
@@ -2169,7 +2169,7 @@ static int opt2host_port(const char*		optarg_arg,
 {
 	char optarg[strlen(optarg_arg) + 1];
 
-	strncpy(optarg, optarg_arg, strlen(optarg_arg));
+	strcpy(optarg, optarg_arg);
 	long p;
 	char* endptr;
 	char* sep = strchr(optarg, ':');
@@ -2296,8 +2296,8 @@ static void lircd_parse_options(int argc, char** const argv)
 			options_set_opt("lircd:output", optarg);
 			break;
 		case 'l':
-			options_set_opt("lircd:listen", "True");
-			options_set_opt("lircd:listen_hostport", optarg);
+			options_set_opt("lircd:listen",
+					optarg ? optarg : "0.0.0.0:8765");
 			break;
 		case 'c':
 			options_set_opt("lircd:connect", optarg);
@@ -2403,7 +2403,7 @@ int main(int argc, char** argv)
 		lirc_log_set_file(opt);
 	if (options_getstring("lircd:listen") != NULL) {
 		listen_tcpip = 1;
-		opt = options_getstring("lircd:listen_hostport");
+		opt = options_getstring("lircd:listen");
 		if (opt) {
 			if (opt2host_port(opt, &address, &port, errmsg) != 0) {
 				fputs(errmsg, stderr);
diff --git a/doc/man-source/lircd.8 b/doc/man-source/lircd.8
index df0a5e4..1aa036f 100644
--- a/doc/man-source/lircd.8
+++ b/doc/man-source/lircd.8
@@ -1,4 +1,4 @@
-.TH LIRCD "8" "Last change: Aug 2016" "lircd @version@" "System Administration Utilities"
+.TH LIRCD "8" "Last change: Dec 2016" "lircd @version@" "System Administration Utilities"
 .SH NAME
 .P
 \fBlircd\fR - Decode infrared signals and provide them on a socket.
@@ -94,6 +94,7 @@ to all sorts of changes. It has not ben tested thoroughly.
 Let lircd listen for network
 connections on the given address/port. The default address is 0.0.0.0,
 which means that connections on all network interfaces will be accepted.
+The address must be given in dotted numerical form.
 The default port is 8765. No security checks are currently implemented.
 The listening lircd instance will send all IR events to the connecting
 lircd instances.
-- 
2.7.4