From 412232c2efa6b0ff964e06d3ce641bacccbd69c7 Mon Sep 17 00:00:00 2001 From: Gerard Wagener Date: Fri, 18 Jan 2019 16:32:18 +0100 Subject: [PATCH] chg: [client] Remove last \n from config data --- client/d4.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/client/d4.c b/client/d4.c index ab39c59..8aff813 100644 --- a/client/d4.c +++ b/client/d4.c @@ -112,6 +112,8 @@ int d4_load_config(d4_t* d4) { int i; int fd; + int n; + int j; char *buf; buf=calloc(1,2*FILENAME_MAX); if (buf) { @@ -120,7 +122,16 @@ int d4_load_config(d4_t* d4) fd = open(buf,O_RDONLY); if (fd > 0) { //FIXME error handling - read(fd, d4->conf[i], SZCONFVALUE); + n = read(fd, d4->conf[i], SZCONFVALUE); + if (n > 0) { + //Remove the last new line + for (j=n; j>=0; --j) { + if (d4->conf[i][j]== '\n') { + d4->conf[i][j] = '\0'; + break; + } + } + } close(fd); } else { d4->errno_copy = errno;