diff options
| author | jvoisin | 2018-01-15 16:56:00 +0100 |
|---|---|---|
| committer | jvoisin | 2018-01-15 16:56:00 +0100 |
| commit | e9b99a26f7c9d7e656e08c3c9ef6dc9afafcb327 (patch) | |
| tree | 77789cbe61bcf7328adf6b22ed0a058f6301c8f1 | |
| parent | 86b5068496ad86da71e2de4fcb8db0c2347a7f98 (diff) | |
Fix an off-by-one
| -rw-r--r-- | src/sp_config.c | 2 |
1 files changed, 1 insertions, 1 deletions
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) { | |||
| 177 | while (getline(&lineptr, &n, fd) > 0) { | 177 | while (getline(&lineptr, &n, fd) > 0) { |
| 178 | /* We trash the terminal `\n`. This simplify the display of logs. */ | 178 | /* We trash the terminal `\n`. This simplify the display of logs. */ |
| 179 | if (lineptr[strlen(lineptr) - 1] == '\n') { | 179 | if (lineptr[strlen(lineptr) - 1] == '\n') { |
| 180 | if (lineptr[strlen(lineptr) - 2] == '\r') { | 180 | if (strlen(lineptr) >= 2 && lineptr[strlen(lineptr) - 2] == '\r') { |
| 181 | lineptr[strlen(lineptr) - 2] = '\0'; | 181 | lineptr[strlen(lineptr) - 2] = '\0'; |
| 182 | } else { | 182 | } else { |
| 183 | lineptr[strlen(lineptr) - 1] = '\0'; | 183 | lineptr[strlen(lineptr) - 1] = '\0'; |
