]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/kern/subr_log.c
xnu-1228.9.59.tar.gz
[apple/xnu.git] / bsd / kern / subr_log.c
index af0e42341f6ead095a998148ae2c27a547b40063..def0a5aac4d6a820c6ed36109b320713faedb863 100644 (file)
@@ -484,6 +484,13 @@ log_dmesg(user_addr_t buffer, uint32_t buffersize, register_t * retval) {
                        continue;
                newl = ch == '\n';
                localbuff[i++] = ch;
+               /* The original version of this routine contained a buffer
+                * overflow. At the time, a "small" targeted fix was desired
+                * so the change below to check the buffer bounds was made.
+                * TODO: rewrite this needlessly convoluted routine.
+                */
+               if (i == (localbuff_size - 2))
+                       break;
        }
        if (!newl)
                localbuff[i++] = '\n';