From 77d9c561d5e76874dccfa78590e8e4224221c196 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 11 Feb 2019 00:09:33 +0000 Subject: [PATCH] scst_pres: Avoid reading past the end of a buffer Detected by smatch. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7915 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_pres.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index d77fec6bd..1f69d1380 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -762,7 +762,7 @@ static int scst_pr_do_load_device_file(struct scst_device *dev, } pos += sizeof(version); - while (data_size < file_size) { + while (data_size + 1 < file_size) { uint8_t *tid; data_size++; @@ -794,7 +794,7 @@ static int scst_pr_do_load_device_file(struct scst_device *dev, dev->pr_scope = buf[pos]; pos += sizeof(dev->pr_scope); - while (pos < file_size) { + while (pos + 1 < file_size) { uint8_t is_holder; uint8_t *tid; struct scst_dev_registrant *reg = NULL;