From e9b99a26f7c9d7e656e08c3c9ef6dc9afafcb327 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 15 Jan 2018 16:56:00 +0100 Subject: Fix an off-by-one --- src/sp_config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sp_config.c b/src/sp_config.c index 4037e26..7a38a45 100644 --- a/src/sp_config.c +++ b/src/sp_config.c @@ -177,7 +177,7 @@ int sp_parse_config(const char *conf_file) { while (getline(&lineptr, &n, fd) > 0) { /* We trash the terminal `\n`. This simplify the display of logs. */ if (lineptr[strlen(lineptr) - 1] == '\n') { - if (lineptr[strlen(lineptr) - 2] == '\r') { + if (strlen(lineptr) >= 2 && lineptr[strlen(lineptr) - 2] == '\r') { lineptr[strlen(lineptr) - 2] = '\0'; } else { lineptr[strlen(lineptr) - 1] = '\0'; -- cgit v1.3