[PATCH 06/14] Cleanup: ensure string is 0 terminated

Dirk Hohndel dirk at hohndel.org
Thu Dec 28 16:35:34 PST 2017


Coverity CID 207790

Signed-off-by: Dirk Hohndel <dirk at hohndel.org>
---
 src/irda.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/irda.c b/src/irda.c
index 149808aaa5c2..2964d4d8cb3a 100644
--- a/src/irda.c
+++ b/src/irda.c
@@ -229,10 +229,12 @@ dc_irda_connect_name (dc_iostream_t *abstract, unsigned int address, const char
 	struct sockaddr_irda peer;
 	peer.sir_family = AF_IRDA;
 	peer.sir_addr = address;
-	if (name)
+	if (name) {
 		strncpy (peer.sir_name, name, 25);
-	else
+		peer.sir_name[24] = '\0';
+	} else {
 		memset (peer.sir_name, 0x00, 25);
+	}
 #endif
 
 	return dc_socket_connect (&device->base, (struct sockaddr *) &peer, sizeof (peer));
-- 
2.15.1



More information about the devel mailing list