Commit e6cfaf34 authored by Linus Torvalds's avatar Linus Torvalds

proc: avoid integer type confusion in get_proc_long

proc_get_long() is passed a size_t, but then assigns it to an 'int'
variable for the length.  Let's not do that, even if our IO paths are
limited to MAX_RW_COUNT (exactly because of these kinds of type errors).

So do the proper test in the rigth type.
Reported-by: default avatarKyle Zeng <zengyhkyle@gmail.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b52be557
...@@ -342,13 +342,12 @@ static int proc_get_long(char **buf, size_t *size, ...@@ -342,13 +342,12 @@ static int proc_get_long(char **buf, size_t *size,
unsigned long *val, bool *neg, unsigned long *val, bool *neg,
const char *perm_tr, unsigned perm_tr_len, char *tr) const char *perm_tr, unsigned perm_tr_len, char *tr)
{ {
int len;
char *p, tmp[TMPBUFLEN]; char *p, tmp[TMPBUFLEN];
ssize_t len = *size;
if (!*size) if (len <= 0)
return -EINVAL; return -EINVAL;
len = *size;
if (len > TMPBUFLEN - 1) if (len > TMPBUFLEN - 1)
len = TMPBUFLEN - 1; len = TMPBUFLEN - 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment