mirror of https://gitee.com/openkylin/linux.git
s390/dcssblk: correct out of bounds array indexes
Fix a couple of warnings like this: [linux-4.2-rc7/drivers/s390/block/dcssblk.c:553]: (style) Array index 'j' is used before limits check. Reported-by: David Binderman <dcb314@hotmail.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
parent
78fb907626
commit
42cfc6b590
|
@ -548,10 +548,10 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char
|
||||||
*/
|
*/
|
||||||
num_of_segments = 0;
|
num_of_segments = 0;
|
||||||
for (i = 0; (i < count && (buf[i] != '\0') && (buf[i] != '\n')); i++) {
|
for (i = 0; (i < count && (buf[i] != '\0') && (buf[i] != '\n')); i++) {
|
||||||
for (j = i; (buf[j] != ':') &&
|
for (j = i; j < count &&
|
||||||
|
(buf[j] != ':') &&
|
||||||
(buf[j] != '\0') &&
|
(buf[j] != '\0') &&
|
||||||
(buf[j] != '\n') &&
|
(buf[j] != '\n'); j++) {
|
||||||
j < count; j++) {
|
|
||||||
local_buf[j-i] = toupper(buf[j]);
|
local_buf[j-i] = toupper(buf[j]);
|
||||||
}
|
}
|
||||||
local_buf[j-i] = '\0';
|
local_buf[j-i] = '\0';
|
||||||
|
@ -723,7 +723,7 @@ dcssblk_remove_store(struct device *dev, struct device_attribute *attr, const ch
|
||||||
/*
|
/*
|
||||||
* parse input
|
* parse input
|
||||||
*/
|
*/
|
||||||
for (i = 0; ((*(buf+i)!='\0') && (*(buf+i)!='\n') && i < count); i++) {
|
for (i = 0; (i < count && (*(buf+i)!='\0') && (*(buf+i)!='\n')); i++) {
|
||||||
local_buf[i] = toupper(buf[i]);
|
local_buf[i] = toupper(buf[i]);
|
||||||
}
|
}
|
||||||
local_buf[i] = '\0';
|
local_buf[i] = '\0';
|
||||||
|
@ -904,10 +904,10 @@ dcssblk_check_params(void)
|
||||||
|
|
||||||
for (i = 0; (i < DCSSBLK_PARM_LEN) && (dcssblk_segments[i] != '\0');
|
for (i = 0; (i < DCSSBLK_PARM_LEN) && (dcssblk_segments[i] != '\0');
|
||||||
i++) {
|
i++) {
|
||||||
for (j = i; (dcssblk_segments[j] != ',') &&
|
for (j = i; (j < DCSSBLK_PARM_LEN) &&
|
||||||
|
(dcssblk_segments[j] != ',') &&
|
||||||
(dcssblk_segments[j] != '\0') &&
|
(dcssblk_segments[j] != '\0') &&
|
||||||
(dcssblk_segments[j] != '(') &&
|
(dcssblk_segments[j] != '('); j++)
|
||||||
(j < DCSSBLK_PARM_LEN); j++)
|
|
||||||
{
|
{
|
||||||
buf[j-i] = dcssblk_segments[j];
|
buf[j-i] = dcssblk_segments[j];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue