From 5920dbf73ae170392e43e393e9c1d5983943300f Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 14 May 2013 22:49:48 +0200 Subject: [PATCH] lldpcli: don't rely on `fgetln()` providing a NULL-terminated string From the manual page of some BSD, this is not the case. --- src/client/lldpcli.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/client/lldpcli.c b/src/client/lldpcli.c index 3547039d..c29853b4 100644 --- a/src/client/lldpcli.c +++ b/src/client/lldpcli.c @@ -472,10 +472,12 @@ main(int argc, char *argv[]) size_t len; char *line; while ((line = fgetln(file, &len))) { + line = strndup(line, len); if (line[len - 1] == '\n') { line[len - 1] = '\0'; parse_and_exec(conn, fmt, line); } + free(line); } fclose(file); } else { -- 2.39.5