瀏覽代碼

Ensure that line_size >= 1 before trying to trim input string.

See: https://bugs.torproject.org/28179
Alexander Færøy 5 年之前
父節點
當前提交
c8b8b15f0e
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/lib/process/process.c

+ 2 - 2
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;
     }