diff options
author | Jeff Dike <jdike@addtoit.com> | 2006-06-30 10:55:54 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-30 20:25:37 +0200 |
commit | c2b7a4bb30008dc256d63802e02b6fb950958443 (patch) | |
tree | 355e20a2295099dad5878c2034d39739e984d9d1 /arch/um | |
parent | [PATCH] UML: fix the INIT_ENV_ARG_LIMIT dependencies (diff) | |
download | linux-c2b7a4bb30008dc256d63802e02b6fb950958443.tar.xz linux-c2b7a4bb30008dc256d63802e02b6fb950958443.zip |
[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: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um')
-rw-r--r-- | arch/um/os-Linux/mem.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c index c6432e729241..d24d1a960523 100644 --- a/arch/um/os-Linux/mem.c +++ b/arch/um/os-Linux/mem.c @@ -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; } |