[PATCH] rev: Avoid out of boundary read

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Check if the length of the parsed string is at least 1,
otherwise an out of boundary read would occur.
---
 text-utils/rev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/text-utils/rev.c b/text-utils/rev.c
index ace2cd6..735aaef 100644
--- a/text-utils/rev.c
+++ b/text-utils/rev.c
@@ -149,6 +149,9 @@ int main(int argc, char *argv[])
 		while (fgetws(buf, bufsiz, fp)) {
 			len = wcslen(buf);
 
+			if (len == 0)
+				continue;
+
 			/* This is my hack from setpwnam.c -janl */
 			while (buf[len-1] != '\n' && !feof(fp)) {
 				/* Extend input buffer if it failed getting the whole line */
-- 
2.10.0

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux