]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] uml: fix /proc/mounts parsing boundary condition
authorJeff Dike <jdike@addtoit.com>
Fri, 30 Jun 2006 08:55:54 +0000 (01:55 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 30 Jun 2006 18:25:37 +0000 (11:25 -0700)
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>
arch/um/os-Linux/mem.c

index c6432e7292411de1ea2006aabf97a13c3a7fa4eb..d24d1a9605237830c9da6fb7246b9ffc52bad62a 100644 (file)
@@ -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;
 }