all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] fix #3017: check array boundaries before using
Date: Mon, 21 Sep 2020 09:12:32 +0200	[thread overview]
Message-ID: <20200921071232.2085-1-d.csapak@proxmox.com> (raw)

else we panic here

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/server/worker_task.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/server/worker_task.rs b/src/server/worker_task.rs
index 0f7e291a..771e8447 100644
--- a/src/server/worker_task.rs
+++ b/src/server/worker_task.rs
@@ -210,7 +210,7 @@ pub fn upid_read_status(upid: &UPID) -> Result<TaskState, Error> {
     file.read_to_end(&mut data)?;
 
     // task logs should end with newline, we do not want it here
-    if data[data.len()-1] == b'\n' {
+    if data.len() > 0 && data[data.len()-1] == b'\n' {
         data.pop();
     }
 
@@ -218,7 +218,7 @@ pub fn upid_read_status(upid: &UPID) -> Result<TaskState, Error> {
         let mut start = 0;
         for pos in (0..data.len()).rev() {
             if data[pos] == b'\n' {
-                start = pos + 1;
+                start = data.len().min(pos + 1);
                 break;
             }
         }
-- 
2.20.1





             reply	other threads:[~2020-09-21  7:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-21  7:12 Dominik Csapak [this message]
2020-09-21  7:21 ` [pbs-devel] applied: " Dietmar Maurer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200921071232.2085-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal