XQuartz: Fix an array-index-out-of-bounds crasher
authorJeremy Huddleston <jeremyhu@apple.com>
Sat, 14 May 2011 21:09:45 +0000 (14:09 -0700)
committerJeremy Huddleston <jeremyhu@apple.com>
Sun, 15 May 2011 02:15:26 +0000 (19:15 -0700)
Found-by: GuardMalloc
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
hw/xquartz/console_redirect.c

index cdd2b89..70a819e 100644 (file)
@@ -116,7 +116,7 @@ static inline int _read_redirect(int fd, int flush) {
                 *s='\0';
                 asl_log(aslr->asl, aslr->msg, aslr->level, "%s", p);
             } else if(aslr->buf != p) {
-                memmove(aslr->buf, p, BUF_SIZE);
+                memmove(aslr->buf, p, BUF_SIZE - (p - aslr->buf));
                 aslr->w = aslr->buf + (s - p);
                 break;
             } else if(nbytes == BUF_SIZE - 1) {