mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-11-30 21:44:06 +08:00
block: sed-opal: Fix a couple off by one bugs
resp->num is the number of tokens in resp->tok[]. It gets set in
response_parse(). So if n == resp->num then we're reading beyond the
end of the data.
Fixes: 455a7b238c
("block: Add Sed-opal library")
Reviewed-by: Scott Bauer <scott.bauer@intel.com>
Tested-by: Scott Bauer <scott.bauer@intel.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
a1e7918862
commit
ce042c183b
@ -877,7 +877,7 @@ static size_t response_get_string(const struct parsed_resp *resp, int n,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (n > resp->num) {
|
||||
if (n >= resp->num) {
|
||||
pr_debug("Response has %d tokens. Can't access %d\n",
|
||||
resp->num, n);
|
||||
return 0;
|
||||
@ -916,7 +916,7 @@ static u64 response_get_u64(const struct parsed_resp *resp, int n)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (n > resp->num) {
|
||||
if (n >= resp->num) {
|
||||
pr_debug("Response has %d tokens. Can't access %d\n",
|
||||
resp->num, n);
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user