提交 c2b7a4bb 编写于 作者: J Jeff Dike 提交者: Linus Torvalds

[PATCH] uml: fix /proc/mounts parsing boundary condition

When parsing /proc/mounts looking for a tmpfs mount on /dev/shm, if a string
that we are looking for if split across reads, then it won't be recognized.

Fix this by refilling the buffer whenever we advance the cursor.
Signed-off-by: NJeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 dd673bca
......@@ -55,7 +55,7 @@ static void __init find_tempdir(void)
*/
static int next(int fd, char *buf, int size, char c)
{
int n;
int n, len;
char *ptr;
while((ptr = strchr(buf, c)) == NULL){
......@@ -69,7 +69,17 @@ static int next(int fd, char *buf, int size, char c)
}
ptr++;
memmove(buf, ptr, strlen(ptr) + 1);
len = strlen(ptr);
memmove(buf, ptr, len + 1);
/* Refill the buffer so that if there's a partial string that we care
* about, it will be completed, and we can recognize it.
*/
n = read(fd, &buf[len], size - len - 1);
if(n < 0)
return -errno;
buf[len + n] = '\0';
return 1;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册