aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2018-12-14 03:31:56 +0100
committerNick Mathewson <nickm@torproject.org>2018-12-17 16:39:28 -0500
commitc8b8b15f0eb2651dea694a057e70e6b8c34dbe05 (patch)
tree84a38b2c9e2646dfb3b8ecf24873287798136e96
parent651cdd05b7071bff4da7c3335f697d90c82c9f3e (diff)
downloadtor-c8b8b15f0eb2651dea694a057e70e6b8c34dbe05.tar.gz
tor-c8b8b15f0eb2651dea694a057e70e6b8c34dbe05.zip
Ensure that line_size >= 1 before trying to trim input string.
See: https://bugs.torproject.org/28179
-rw-r--r--src/lib/process/process.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/process/process.c b/src/lib/process/process.c
index fb76a0a725..b3370e919f 100644
--- a/src/lib/process/process.c
+++ b/src/lib/process/process.c
@@ -766,13 +766,13 @@ process_read_lines(process_t *process,
tor_assert(ret != -1);
/* Remove \n from the end of the line. */
- if (data[line_size - 1] == '\n') {
+ if (line_size >= 1 && data[line_size - 1] == '\n') {
data[line_size - 1] = '\0';
--line_size;
}
/* Remove \r from the end of the line. */
- if (data[line_size - 1] == '\r') {
+ if (line_size >= 1 && data[line_size - 1] == '\r') {
data[line_size - 1] = '\0';
--line_size;
}